Skip to content

Commit

Permalink
add watch-detector
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Jul 27, 2018
1 parent 26cd9b8 commit 829cb0c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const NodeWatcher = require('./src/node_watcher');
const PollWatcher = require('./src/poll_watcher');
const WatchmanWatcher = require('./src/watchman_watcher');
const FSEventsWatcher = require('./src/fsevents_watcher');
const WatchDetector = require('watch-detector');

function sane(dir, options) {
options = options || {};
Expand All @@ -16,6 +17,18 @@ function sane(dir, options) {
return new WatchmanWatcher(dir, options);
} else if (options.fsevents) {
return new FSEventsWatcher(dir, options);
} else if (options.auto) {
delete options.auto;
const detector = new WatchDetector({
fs: require('fs'),
root: dir,
ui: {
writeLine(message) {
console.log(message);
},
},
});
return sane(dir, detector.findBestWatcherOption(options));
} else {
return new NodeWatcher(dir, options);
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"micromatch": "^3.1.4",
"minimist": "^1.1.1",
"walker": "~1.0.5",
"watch": "~0.18.0"
"watch": "~0.18.0",
"watch-detector": "^0.1.0"
},
"devDependencies": {
"eslint": "^3.19.0",
Expand Down

0 comments on commit 829cb0c

Please sign in to comment.