From 80c6def1fd87c2793f6e9dd1664332363e864d41 Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Wed, 15 Aug 2018 22:39:26 +0200 Subject: [PATCH] refactor: split the docs build task to `docs:pages` and `docs:search` The `finish` gulp event is an stream internal event and is not suitable to chain tasks. Changes: - Move pages building to the `docs:pages` and `docs:pages:all` subtasks - Move search entries building to the `docs:search` subtask --- gulp/tasks/docs.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/gulp/tasks/docs.js b/gulp/tasks/docs.js index b1290fcbd..ed41da82b 100644 --- a/gulp/tasks/docs.js +++ b/gulp/tasks/docs.js @@ -41,8 +41,13 @@ supercollider .adapter('sass') .adapter('js'); -// Assembles the layout, pages, and partials in the docs folder -gulp.task('docs', function() { +// Build the search entries +gulp.task('docs:search', function (done) { + supercollider.buildSearch('_build/data/search.json', done); +}); + +// Assembles the modified layout, pages, and partials in the docs folder +gulp.task('docs:pages', function() { return gulp.src('docs/pages/**/*') .pipe(newer({ dest: '_build', @@ -51,30 +56,28 @@ gulp.task('docs', function() { .pipe(supercollider.init()) .pipe(panini(PANINI_CONFIG)) .pipe(cacheBust({ - basePath: '_build/' + basePath: '_build/' })) - .pipe(gulp.dest('_build')) - .on('finish', buildSearch); + .pipe(gulp.dest('_build')); }); -gulp.task('docs:all', function() { +// Assembles layout, pages, and partials in the docs folder, even if not modified +gulp.task('docs:pages:all', function() { panini.refresh(); return gulp.src('docs/pages/**/*') .pipe(supercollider.init()) .pipe(panini(PANINI_CONFIG)) .pipe(cacheBust({ - basePath: '_build/' + basePath: '_build/' })) - .pipe(gulp.dest('_build')) - .on('finish', buildSearch); + .pipe(gulp.dest('_build')); }); -function buildSearch() { - supercollider.buildSearch('_build/data/search.json', function() {}); -} - gulp.task('docs:debug', gulp.series('docs:all', function(done) { var output = JSON.stringify(supercollider.tree, null, ' '); require('fs').writeFile('./_debug.json', output, done); })); + +gulp.task('docs', gulp.series('docs:pages', 'docs:search')); +gulp.task('docs:all', gulp.series('docs:pages:all', 'docs:search')); -- 2.47.2