]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
refactor: split the docs build task to `docs:pages` and `docs:search`
authorNicolas Coden <nicolas@ncoden.fr>
Wed, 15 Aug 2018 20:39:26 +0000 (22:39 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Wed, 15 Aug 2018 20:49:05 +0000 (22:49 +0200)
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

index b1290fcbd37f3ea5148a54c2de238a48c6b4e9ea..ed41da82b1c34e193181bff48751759523d6573b 100644 (file)
@@ -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'));