From dcd3ab813f03b039e142af08a32cf488bda11d79 Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Sun, 1 Jul 2018 19:46:22 +0200 Subject: [PATCH] fix: remove run-sequence from gulp `deploy:dist` task to detect its end `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 | 107 ++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/gulp/tasks/deploy.js b/gulp/tasks/deploy.js index 58e7c544be..5e60b48386 100644 --- a/gulp/tasks/deploy.js +++ b/gulp/tasks/deploy.js @@ -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