Skip to content

Instantly share code, notes, and snippets.

@floatdrop
Last active January 2, 2016 11:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floatdrop/8294178 to your computer and use it in GitHub Desktop.
Save floatdrop/8294178 to your computer and use it in GitHub Desktop.
Experementall stuff with gulp-watch
var watch = require('gulp-watch');
var es = require('event-stream');
var gulp = require('gulp');
gulp.task('default', function(cb) {
gulp.src('list.js')
.pipe(watch({name: 'Meta watcher'}))
.pipe(new es.through(function(file) {
var self = this;
delete require.cache[require.resolve(file.path)];
require(file.path).forEach(function(line) {
gulp.src(line, { read: false })
.on('data', self.emit.bind(self, 'data'));
});
}))
.pipe(watch({name: 'Real watcher', passThrough: false}))
.on('data', function (data) {
console.log('Post: ' + data.path);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment