Skip to content

Instantly share code, notes, and snippets.

@bhavjot
Created February 15, 2018 03:59
Show Gist options
  • Save bhavjot/efadd67ee07c4c83afb8052a92e5d791 to your computer and use it in GitHub Desktop.
Save bhavjot/efadd67ee07c4c83afb8052a92e5d791 to your computer and use it in GitHub Desktop.
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