Watch files and directories with glob patterns
npm install watch-glob
watchGlob(patterns, [options], addedCallback, [removedCallback] ])
patterns
- a glob pattern or array of glob patterns to watchoptions
- the base folder in which to search for the patterns (equivalent tooptions.cwd
) an options object to pass toglob()
, plus the following:callbackArg
- how the file should be represented on the callbackabsolute
- absolute pathrelative
- path relative to `options.cwd´vinyl
- a vinyl-fs object (experimental)object
(default) - { base, path, relative }
delay
- (default:2000
) sometimes Gaze does not seem to correctly watch folders which have not been created yet. Therefore, a 2000ms delay is used
updateCallback
- function to be called when a file is changed, created, or "created" through a renameremoveCallback
- function to be called after a file is is deleted or "deleted" through a rename
var watchGlob = require('watch-glob'),
coffee = require('coffee-files');
watchGlob(['tmp/**/*', 'lib/**/*'], { callbackArg: 'relative' }, function(filePath) {
// Perform livereload
});
watchGlob('coffee/**/*.coffee', { cwd: 'src' }, function(filepath) {
coffee.file(filepath.path, 'build/' + filepath.relative);
});