Gulp (4.0) throws the error "Error: Invalid glob argument: undefined"
when I attempt to gulp.src
the path of a changed file obtained from gulp.watch
. Both this:
gulp.task('watch', function() {
gulp.watch('./web/**/*.html')
.on('change', function(file) {
gulp.src(file.path)
.pipe(gulp.dest('./output'));
});
});
and this syntax variant:
gulp.task('watch', function() {
gulp.watch('./web/**/*.html', function(file) {
gulp.src(file.path)
.pipe(gulp.dest('./output'));
});
});
yield the same result.
Logging file.path before the gulp.src
also outputs "undefined".
To reproduce:
npm install -g gulp@github:gulpjs/gulp#4.0
and create a gulpfile.js
containing:
const gulp = require('gulp');
followed by either of the examples.
My understanding is that this is the way in which the changed file's path should be accessible as per the docs, so I'm not sure where I'm going wrong?