]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: remove run-sequence from gulp `deploy:dist` task to detect its end 11346/head
authorNicolas Coden <nicolas@ncoden.fr>
Sun, 1 Jul 2018 17:46:22 +0000 (19:46 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Sun, 1 Jul 2018 17:46:22 +0000 (19:46 +0200)
`run-sequence` doesn't match well with multile streams from `gulp-filter` and prevent us to use the stream end event or gulp to automatically detect the stream end. This commit refactor the `deploy:dist` task and move its logics to `deploy:dist:files` in order to make gulp dealing directly with the `gulp-filter` stream and detect its end.

gulp/tasks/deploy.js

index 58e7c544beb831ca00faba2eca1e290e423d8c20..5e60b4838619de69dc38acb6406d57beb4408c1c 100644 (file)
@@ -25,6 +25,9 @@ gulp.task('deploy:prep', function(cb) {
   sequence('deploy:prompt', 'deploy:version', 'deploy:dist', 'deploy:plugins', 'deploy:settings', cb);
 });
 
+gulp.task('deploy:dist', function (cb) {
+  sequence('sass:foundation', 'javascript:foundation', 'deploy:dist:files', cb);
+});
 
 gulp.task('deploy:prompt', function(cb) {
   inquirer.prompt([{
@@ -41,62 +44,60 @@ gulp.task('deploy:prompt', function(cb) {
 // Bumps the version number in any file that has one
 gulp.task('deploy:version', function() {
   return gulp.src(CONFIG.VERSIONED_FILES, { base: process.cwd() })
-    .pipe(replace(CURRENT_VERSION, NEXT_VERSION))
-    .pipe(gulp.dest('.'));
+  .pipe(replace(CURRENT_VERSION, NEXT_VERSION))
+  .pipe(gulp.dest('.'));
 });
 
 // Generates compiled CSS and JS files and sourcemaps and puts them in the dist/ folder
-gulp.task('deploy:dist', function() {
-  sequence('sass:foundation', 'javascript:foundation', function() {
-    var cssFilter = filter(['**/*.css'], { restore: true });
-    var jsFilter  = filter(['**/*.js'], { restore: true });
-    var cssSourcemapFilter = filter(['**/*.css.map'], { restore: true });
-    var jsSourcemapFilter = filter(['**/*.js.map'], { restore: true });
-    var tsFilter  = filter(['**/*.ts'], { restore: true });
-
-    return gulp.src(CONFIG.DIST_FILES)
-      .pipe(plumber())
-
-      // --- Source maps ---
-      // * Copy sourcemaps to the dist folder
-      // This is done first to avoid collision with minified-sourcemaps.
-      .pipe(cssSourcemapFilter)
-        .pipe(gulp.dest('./dist/css'))
-        .pipe(cssSourcemapFilter.restore)
-      .pipe(jsSourcemapFilter)
-        .pipe(gulp.dest('./dist/js'))
-        .pipe(jsSourcemapFilter.restore)
-
-      // --- Source files ---
-      // * Copy source files to dist folder
-      // * Create minified files
-      // * Create minified-sourcemaps based on standard sourcemaps.
-      //   Sourcemaps are initialized before the ".min" renaming to be able retrieve
-      //   original sourcemaps from source names.
-      .pipe(cssFilter)
-        .pipe(gulp.dest('./dist/css'))
-        .pipe(sourcemaps.init({ loadMaps: true }))
-        .pipe(rename({ suffix: '.min' }))
-        .pipe(cleancss({ compatibility: 'ie9' }))
-        .pipe(sourcemaps.write('.'))
-        .pipe(gulp.dest('./dist/css'))
-        .pipe(cssFilter.restore)
-
-      .pipe(jsFilter)
-        .pipe(gulp.dest('./dist/js'))
-        .pipe(sourcemaps.init({ loadMaps: true }))
-        .pipe(rename({ suffix: '.min' }))
-        .pipe(uglify())
-        .pipe(sourcemaps.write('.'))
-        .pipe(gulp.dest('./dist/js'))
-        .pipe(jsFilter.restore)
-
-      // --- TypeScript files ---
-      // * Copy typescript files to the dist folder
-      .pipe(tsFilter)
-        .pipe(gulp.dest('./dist/js'))
-        .pipe(tsFilter.restore)
-  });
+gulp.task('deploy:dist:files', function() {
+  var cssFilter = filter(['**/*.css'], { restore: true });
+  var jsFilter  = filter(['**/*.js'], { restore: true });
+  var cssSourcemapFilter = filter(['**/*.css.map'], { restore: true });
+  var jsSourcemapFilter = filter(['**/*.js.map'], { restore: true });
+  var tsFilter  = filter(['**/*.ts'], { restore: true });
+
+  return gulp.src(CONFIG.DIST_FILES)
+    .pipe(plumber())
+
+    // --- Source maps ---
+    // * Copy sourcemaps to the dist folder
+    // This is done first to avoid collision with minified-sourcemaps.
+    .pipe(cssSourcemapFilter)
+      .pipe(gulp.dest('./dist/css'))
+      .pipe(cssSourcemapFilter.restore)
+    .pipe(jsSourcemapFilter)
+      .pipe(gulp.dest('./dist/js'))
+      .pipe(jsSourcemapFilter.restore)
+
+    // --- Source files ---
+    // * Copy source files to dist folder
+    // * Create minified files
+    // * Create minified-sourcemaps based on standard sourcemaps.
+    //   Sourcemaps are initialized before the ".min" renaming to be able retrieve
+    //   original sourcemaps from source names.
+    .pipe(cssFilter)
+      .pipe(gulp.dest('./dist/css'))
+      .pipe(sourcemaps.init({ loadMaps: true }))
+      .pipe(rename({ suffix: '.min' }))
+      .pipe(cleancss({ compatibility: 'ie9' }))
+      .pipe(sourcemaps.write('.'))
+      .pipe(gulp.dest('./dist/css'))
+      .pipe(cssFilter.restore)
+
+    .pipe(jsFilter)
+      .pipe(gulp.dest('./dist/js'))
+      .pipe(sourcemaps.init({ loadMaps: true }))
+      .pipe(rename({ suffix: '.min' }))
+      .pipe(uglify())
+      .pipe(sourcemaps.write('.'))
+      .pipe(gulp.dest('./dist/js'))
+      .pipe(jsFilter.restore)
+
+    // --- TypeScript files ---
+    // * Copy typescript files to the dist folder
+    .pipe(tsFilter)
+      .pipe(gulp.dest('./dist/js'))
+      .pipe(tsFilter.restore);
 });
 
 // Copies standalone JavaScript plugins to dist/ folder