1

I'm building a simple gulp watch task,

gulp.task('serve', function () {
    console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});

gulp.task('default', [


], function () {
    gulp.watch([
        './index.js',
        './views/**/*.pug'
    ], function (event) {
        gulp.start('serve');
    });
});

I want to pass event object in gulp.start and catch in serve task.

  • 2
    You can't pass arguments to gulp tasks, see https://stackoverflow.com/questions/27306844/can-i-pass-arguments-to-a-gulp-task. However, can't you just create a global variable outside of any task, set it in the gulp.watch return(event) function and then access it in the 'serve' task? And gulp.start is deprecated: see https://github.com/gulpjs/gulp/issues/505 – Mark Oct 11 '17 at 15:52
  • 1
    And see https://stackoverflow.com/questions/32670209/gulp-how-to-pass-parameters-from-watch-to-tasks which has a possible solution for you. In the function(event) call a function (not gulp.start) like serve(event) and in that make your gulp.src stream. – Mark Oct 11 '17 at 15:56
  • Yeah, I found it useful...! Thanks. –  Oct 12 '17 at 07:42

0 Answers0