Restarting Nodemon to run gulp tasks

I have the following code in my gulpfile

gulp.task('scripts', function () { gulp.src(paths.browserify) .pipe(browserify()) .pipe(gulp.dest('./build/js')) .pipe(refresh(server)); }); gulp.task('lint', function () { gulp.src(paths.js) .pipe(jshint()) .pipe(jshint.reporter(stylish)); }); gulp.task('nodemon', function () { nodemon({ script: 'app.js' }); }); 

I need to run lint scripts and tasks when restarting Nodemon. I have the following

 gulp.task('nodemon', function () { nodemon({ script: 'app.js' }).on('restart', function () { gulp.run(['scripts', 'lint']); }); }); 

Gulp.run () is now deprecated, so how could I achieve higher using gulp and best practices?

+7
javascript gulp
source share
2 answers

gulp The nodemon documentation states that you can do this directly by passing an array of tasks to be performed:

 nodemon({script: 'app.js'}).on('restart', ['scripts', 'lint']); 

See the doc here

UPDATE, as the author uses gulp -nodemon:

Idea No. 1, use functions:

 var browserifier = function () { gulp.src(paths.browserify) .pipe(browserify()) .pipe(gulp.dest('./build/js')) .pipe(refresh(server)); }); gulp.task('scripts', browserifier); var linter = function () { gulp.src(paths.js) .pipe(jshint()) .pipe(jshint.reporter(stylish)); }); gulp.task('lint', linter); nodemon({script: 'app.js'}).on('restart', function(){ linter(); browserifier(); }); 
+7
source share

If you can, use the Mangled Deutz feature suggestion. This is the best, most guaranteed way to make sure that it works now and continues.

However, the functions will not help if you need to run dependent tasks or a series of tasks. I wrote a run-sequence to fix this. It does not rely on gulp.run , and it is able to complete the sequence of tasks in order.

+3
source share

All Articles