Skip to content

Instantly share code, notes, and snippets.

@hraban
Last active July 2, 2018 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hraban/31d1331dfe2a435a68ee15e3899ea9fd to your computer and use it in GitHub Desktop.
Save hraban/31d1331dfe2a435a68ee15e3899ea9fd to your computer and use it in GitHub Desktop.
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