From c62d6a0d5092eec7d94f4af92dd8df3f45fa3ae7 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sun, 29 Oct 2023 05:01:25 -0600 Subject: [PATCH] move browserifyPlumber function to global variable; only dist if publish task is detected; alias deploy to publish --- gulpfile.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5473b98..fad9f1c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,7 +19,13 @@ var pkg = require('./package.json'), stylus = require('gulp-stylus'), through = require('through'), uglify = require('gulp-uglify'), - isDist = process.argv.indexOf('deploy') >= 0; + isDist = process.argv.indexOf('publish') >= 0, + // browserifyPlumber fills the role of plumber() when working with browserify + browserifyPlumber = function(e) { + if (isDist) throw e; + log(e.stack); + this.emit('end'); + }; gulp.task('clean:css', del.bind(null, 'public/build/build.css')); @@ -68,7 +74,7 @@ gulp.task('js', gulp.series('clean:js', function _js() { return browserify('src/scripts/main.js', { detectGlobals: false }) .plugin('browser-pack-flat/plugin') .bundle() - .on('error', function(e) { if (isDist) { throw e; } else { log(e.stack); this.emit('end'); } }) + .on('error', browserifyPlumber) .pipe(source('main.bundle.js')) .pipe(buffer()) .pipe(isDist ? uglify() : through()) @@ -81,10 +87,12 @@ gulp.task('build', gulp.series('js', 'html', 'css', 'fonts', 'images')); gulp.task('clean', del.bind(null, 'public')); -gulp.task('deploy', gulp.series('clean', 'build', function _deploy(done) { +gulp.task('publish', gulp.series('clean', 'build', function _deploy(done) { ghpages.publish(path.join(__dirname, 'public'), { logger: log }, done); })); +gulp.task('deploy', gulp.series('publish')); + gulp.task('connect', gulp.series('build', function _connect(done) { connect.server({ root: 'public', port: 8000, livereload: true }); done();