Skip to content

Commit 829cb0c

Browse files
committed
add watch-detector
1 parent 26cd9b8 commit 829cb0c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const NodeWatcher = require('./src/node_watcher');
44
const PollWatcher = require('./src/poll_watcher');
55
const WatchmanWatcher = require('./src/watchman_watcher');
66
const FSEventsWatcher = require('./src/fsevents_watcher');
7+
const WatchDetector = require('watch-detector');
78

89
function sane(dir, options) {
910
options = options || {};
@@ -16,6 +17,18 @@ function sane(dir, options) {
1617
return new WatchmanWatcher(dir, options);
1718
} else if (options.fsevents) {
1819
return new FSEventsWatcher(dir, options);
20+
} else if (options.auto) {
21+
delete options.auto;
22+
const detector = new WatchDetector({
23+
fs: require('fs'),
24+
root: dir,
25+
ui: {
26+
writeLine(message) {
27+
console.log(message);
28+
},
29+
},
30+
});
31+
return sane(dir, detector.findBestWatcherOption(options));
1932
} else {
2033
return new NodeWatcher(dir, options);
2134
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"micromatch": "^3.1.4",
3636
"minimist": "^1.1.1",
3737
"walker": "~1.0.5",
38-
"watch": "~0.18.0"
38+
"watch": "~0.18.0",
39+
"watch-detector": "^0.1.0"
3940
},
4041
"devDependencies": {
4142
"eslint": "^3.19.0",

0 commit comments

Comments
 (0)