Created
November 14, 2016 10:28
-
-
Save nojaf/44c3e6da3f3f4fe252f560931a5afea4 to your computer and use it in GitHub Desktop.
Watch a file and run a command using nodejs
This file contains hidden or 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
const {watch} = require("fs"); | |
const {exec} = require("child_process"); | |
watch("myFolder/myFile.ascx", (eventType,fileName) => { | |
if(eventType == "change"){ | |
console.log("myFile.ascx changed"); | |
exec('xcopy "Some Folder\\myFile.ascx" "Other Folder\\" /Y', () => { | |
console.log("File copied"); | |
}); | |
} | |
}); | |
console.log("Watching myFile.ascx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment