Skip to content

Commit

Permalink
fix(watcher): Close file watchers on exit event
Browse files Browse the repository at this point in the history
  • Loading branch information
xdissent committed Dec 17, 2014
1 parent af808bc commit 7181025
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var getWatchedPatterns = function(patternObjects) {
});
};

exports.watch = function(patterns, excludes, fileList, usePolling) {
exports.watch = function(patterns, excludes, fileList, usePolling, emitter) {
var watchedPatterns = getWatchedPatterns(patterns);
var options = {
usePolling: usePolling,
Expand Down Expand Up @@ -101,7 +101,13 @@ exports.watch = function(patterns, excludes, fileList, usePolling) {
log.debug(e);
});

emitter.on('exit', function(done) {
chokidarWatcher.close();
done();
});

return chokidarWatcher;
};

exports.watch.$inject = ['config.files', 'config.exclude', 'fileList', 'config.usePolling'];
exports.watch.$inject = ['config.files', 'config.exclude', 'fileList', 'config.usePolling',
'emitter'];

0 comments on commit 7181025

Please sign in to comment.