Skip to content

Commit

Permalink
move browserifyPlumber function to global variable; only dist if publ…
Browse files Browse the repository at this point in the history
…ish task is detected; alias deploy to publish
  • Loading branch information
mojavelinux committed Oct 29, 2023
1 parent 2d7fe8a commit c62d6a0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down Expand Up @@ -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())
Expand All @@ -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();
Expand Down

0 comments on commit c62d6a0

Please sign in to comment.