Skip to content

Instantly share code, notes, and snippets.

@RnbWd
Last active August 29, 2015 14:13
Show Gist options
  • Save RnbWd/21cd37654b6926e3043b to your computer and use it in GitHub Desktop.
Save RnbWd/21cd37654b6926e3043b to your computer and use it in GitHub Desktop.
Globby Watcher
//sudo
var globby = require('globby');
var chokidar = require('chokidar');
var task = require('../');
globby(['glob/glob*.glob'], function (err, paths) {
if (err) return cb(err);
task.files = paths;
if (!task.files.length) return;
var watcher = chokidar.watch(task.files, { persistent: true, interval: 250 });
console.log(' ' + chalk.white('watching: ') + chalk.cyan(task.key));
watcher.on('change', function(path) {
if (!task.running) {
console.log(' ' + chalk.white('changed: ') + chalk.cyan(path));
task.run(false, true);
}
});
return watcher;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment