node-sentinel-file-watcher
Linux | OS X | Windows |
---|
|
|
A simple file watcher library for node.
Usage
var nsfw = require('nsfw');
return nsfw(
'dir1',
function(events) {
})
.then(function(watcher) {
return watcher.start();
})
.then(function() {
});
return nsfw(
'dir2',
function(events) {
},
{
debounceMS: 250,
errorCallback(errors) {
}
})
.then(function(watcher) {
return watcher.start();
})
.then(function() {
});
Callback Argument
An array of events as they have happened in a directory, it's children, or to a file.
[
{
"action": 2,
"directory": "/home/nsfw/watchDir",
"file": "file1.ext"
},
{
"action": 0,
"directory": "/home/nsfw/watchDir",
"file": "folder"
},
{
"action": 1,
"directory": "home/nsfw/watchDir/testFolder",
"file": "test.ext"
},
{
"action": 3,
"directory": "home/nsfw/watchDir",
"oldFile": "oldname.ext",
"newFile": "newname.ext"
}
]
Event are enumerated by the nsfw.actions enumeration
nsfw.actions = {
CREATED: 0,
DELETED: 1,
MODIFIED: 2,
RENAMED: 3
};