Created
February 23, 2013 00:45
-
-
Save dotfold/5017713 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
exports.watch = function(patterns, excludes, fileList, watchEvents) { | |
var options = { | |
ignorePermissionErrors: true, | |
ignored: createIgnore(excludes) | |
}; | |
var chokidarWatcher = new chokidar.FSWatcher(options); | |
watchPatterns(patterns, chokidarWatcher); | |
var bind = function(fn) { | |
return function(path) { | |
return fn.call(fileList, helper.normalizeWinPath(path)); | |
}; | |
}; | |
var watchEventToHandler = { | |
'add': bind.call(null, fileList.addFile), | |
'change': bind.call(null, fileList.changeFile), | |
'unlink': bind.call(null, fileList.removeFile) | |
}; | |
// register events | |
watchEvents.forEach(function(eventName) { | |
chokidarWatcher.on(eventName, watchEventToHandler[eventName]); | |
}); | |
// register events | |
// chokidarWatcher.on(constant.FILE_ADD, bind(fileList.addFile)) | |
// .on(constant.FILE_CHANGE, bind(fileList.changeFile)) | |
// .on(constant.FILE_UNLINK, bind(fileList.removeFile)); | |
return chokidarWatcher; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment