
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
gulp-watch
Advanced tools
File watcher that uses super-fast chokidar and emits vinyl objects.
npm install --save-dev gulp-watch
var gulp = require('gulp'),
watch = require('gulp-watch');
gulp.task('stream', function () {
// Endless stream mode
return watch('css/**/*.css', { ignoreInitial: false })
.pipe(gulp.dest('build'));
});
gulp.task('callback', function () {
// Callback mode, useful if any plugin in the pipeline depends on the `end`/`flush` event
return watch('css/**/*.css', function () {
gulp.src('css/**/*.css')
.pipe(gulp.dest('build'));
});
});
Protip: until gulpjs 4.0 is released, you can use gulp-plumber to prevent stops on errors.
More examples can be found in docs/readme.md.
Creates a watcher that will spy on files that are matched by glob which can be a
glob string or array of glob strings.
Returns a pass through stream that will emit vinyl files
(with additional event property) that corresponds to event on file-system.
function(vinyl)This function is called when events happen on the file-system.
All incoming files that are piped in are grouped and passed to the events stream as is.
vinyl — is vinyl object that corresponds to the file that caused the event. Additional event field is added to determine what caused changes.Possible events:
add - file was added to watch or createdchange - file was changedunlink - file was deletedThis object is passed to the chokidar options directly. Options for gulp.src are also available. If you do not want content from watch, then add read: false to the options object.
Type: Boolean
Default: true
Indicates whether chokidar should ignore the initial add events or not.
Type: Array
Default: ['add', 'change', 'unlink']
List of events, that should be watched by gulp-watch. Contains event names from chokidar.
Type: String
Default: undefined
Use explicit base path for files from glob. Read more about base and cwd in gulpjs docs.
Type: String
Default: undefined
Name of the watcher. If it is present in options, you will get more readable output.
Type: Boolean
Default: false
This option will enable verbose output.
Type: Number
Default: 10
Wait for readDelay milliseconds before reading the file.
Type: Boolean
Default: true
Setting this to false will return file.contents as null and not read the file at all. Most useful as an optimization if your plugins pipeline doesn't make use of the file contents (e.g. gulp-clean), or to avoid reading the file twice if you use gulp.src() inside the callback instead of the file object that is passed as argument.
Returned Stream from constructor has some useful methods:
add(path / paths)unwatch(path / paths)close()All events from chokidar:
add, change, unlink, addDir, unlinkDir, error, ready, rawMIT (c) 2014 Vsevolod Strukchinsky (floatdrop@gmail.com)
FAQs
Watch, that actually is an endless stream
The npm package gulp-watch receives a total of 137,049 weekly downloads. As such, gulp-watch popularity was classified as popular.
We found that gulp-watch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.