Last active
July 2, 2018 09:06
-
-
Save hraban/31d1331dfe2a435a68ee15e3899ea9fd to your computer and use it in GitHub Desktop.
Simple cross-platform change watcher
This file contains 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
// 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