Created
February 15, 2018 03:59
-
-
Save bhavjot/efadd67ee07c4c83afb8052a92e5d791 to your computer and use it in GitHub Desktop.
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
const nsfw = require('nsfw'); | |
const path = require('path'); | |
function watch(pathParam,fnName) { | |
console.log(pathParam); | |
const absolutePath = pathParam;// path.resolve(pathParam) | |
console.log(`Watching ${absolutePath}`) | |
nsfw(absolutePath, | |
function(events) { | |
console.log(events); | |
for(var i = 0; i < events.length; i++) { | |
const e = events[i]; | |
var output = [ `${actionNames[e.action]}` ] | |
const file = e.file || e.oldFile | |
if(e.action === 0 && file) | |
{ | |
//console.log('Here'); | |
monitorFunctions.log( file, fnName); | |
} | |
// if (file) { | |
// monitorFunctions.log( file, fnName); | |
// //output.push(`${path.join(e.directory, file)}`) | |
// } else { | |
// //output.push(e.directory) | |
// } | |
// if (e.newFile) { | |
// monitorFunctions.log( e.newFile, fnName); | |
// //output.push(`to ${path.join(e.directory, e.newFile)}`); | |
// } | |
//console.log(output.join(' ')) | |
} | |
}) | |
.then(function(watcher) { | |
return watcher.start(); | |
}) | |
.then(function() { | |
//console.log('do nothing'); | |
}) | |
} | |
var actionNames = [ 'Created ', 'Deleted ', 'Modified', 'Renamed ' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment