Last active
January 2, 2016 11:09
-
-
Save floatdrop/8294178 to your computer and use it in GitHub Desktop.
Experementall stuff with gulp-watch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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