Last active
November 6, 2018 00:43
-
-
Save jgwill/82dd3b917a5d0007900f340203a484cf to your computer and use it in GitHub Desktop.
node.js - Watch a folder and execute an action when that happen
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
//@a Watch a folder and do something with the changes | |
var watchPath = "/www/x/fs_watch_folder_1811051535/tests"; | |
console.log("Watching test path: " + watchPath); | |
var fs = require("fs"); | |
var sleep = require("sleep"); | |
fs.watch(watchPath, (eventType, filename) => { | |
console.log(eventType); | |
// could be either 'rename' or 'change'. new file event and delete | |
// also generally emit 'rename' | |
console.log(filename); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment