Skip to content

Instantly share code, notes, and snippets.

@hraban hraban/watch.js
Last active Jul 2, 2018

Embed
What would you like to do?
Simple cross-platform change watcher
// Simplistic directory watcher
//
// example usage:
//
// $ node watch.js | while read line ; do echo compiling ... ; ( while read -r -t 0; do read -r ; done ) ; rm -rf build ; npm run build ; echo done ; done
//
var fs = require('fs');
console.log('listening for changes in src/');
fs.watch('src/', {persistent: true, recursive: true}, function (event, fname) {
console.log(event, fname);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.