Skip to content

Commit

Permalink
🐛 Correctly handle multiple sample builds (ampproject#2172)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasrohmer authored and sebastianbenz committed May 24, 2019
1 parent dbf6dc8 commit 0584559
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions gulpfile.js/build.js
Original file line number Diff line number Diff line change
@@ -69,6 +69,8 @@ function clean() {
project.absolute('pages/.depcache.json'),
project.absolute('pages/podspec.yaml'),

project.absolute('examples/static/samples/samples.json'),

project.paths.GROW_BUILD_DEST,
project.paths.STATICS_DEST,
project.absolute('platform/static'),
@@ -233,7 +235,7 @@ async function fetchArtifacts() {
* @return {Promise}
*/
async function buildPages(done) {
gulp.series(fetchArtifacts, gulp.parallel(buildSamples, buildFrontend),
gulp.series(fetchArtifacts, buildFrontend,
// eslint-disable-next-line prefer-arrow-callback
async function buildGrow() {
config.configureGrow();
@@ -405,7 +407,8 @@ exports.buildPrepare = buildPrepare;
exports.transformPages = transformPages;
exports.fetchArtifacts = fetchArtifacts;
exports.collectStatics = collectStatics;
exports.buildFinalize = gulp.parallel(fetchArtifacts, collectStatics, persistBuildInfo);
exports.buildFinalize = gulp.series(fetchArtifacts,
gulp.parallel(collectStatics, persistBuildInfo));

exports.build = gulp.series(clean, buildPrepare, buildPages,
gulp.parallel(collectStatics, persistBuildInfo));
9 changes: 8 additions & 1 deletion platform/lib/build/samplesBuilder.js
Original file line number Diff line number Diff line change
@@ -314,8 +314,15 @@ class SamplesBuilder {
}
}

return writeFileAsync(SITEMAP_DEST, JSON.stringify(this._sitemap)).then(() => {
return writeFileAsync(SITEMAP_DEST, JSON.stringify(this._sitemap), {
flag: 'wx+',
}).then(() => {
this._log.success('Wrote sample sitemap.');
}).catch(() => {
// An existing sitemap is okay as it is assumed that every other write
// results from a watch-build and would not contain all samples
this._log.info('Samples sitemap already exists');
return;
});
}

0 comments on commit 0584559

Please sign in to comment.