Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ options:
* `watchmanPath`: sets a custom path for `watchman` binary.
* `dot`: enables watching files/directories that start with a dot.
* `ignored`: a glob, regex, function, or array of any combination.
* `auto`: a boolean, which if true will choose the best watcher mode for you. It will choose from Watchman, Node, or Polling modes.

For the glob pattern documentation, see [micromatch](https://github.com/micromatch/micromatch).
If you choose to use `watchman` you'll have to [install watchman yourself](https://facebook.github.io/watchman/docs/install.html)).
Expand Down
12 changes: 12 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,17 @@ function sane(dir, options) {
return new WatchmanWatcher(dir, options);
} else if (options.fsevents) {
return new FSEventsWatcher(dir, options);
} else if (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
66 changes: 63 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,19 @@ has-values@^1.0.0:
is-number "^3.0.0"
kind-of "^4.0.0"

heimdalljs-logger@^0.1.9:
version "0.1.9"
resolved "https://registry.yarnpkg.com/heimdalljs-logger/-/heimdalljs-logger-0.1.9.tgz#d76ada4e45b7bb6f786fc9c010a68eb2e2faf176"
dependencies:
debug "^2.2.0"
heimdalljs "^0.2.0"

heimdalljs@^0.2.0:
version "0.2.5"
resolved "https://registry.yarnpkg.com/heimdalljs/-/heimdalljs-0.2.5.tgz#6aa54308eee793b642cff9cf94781445f37730ac"
dependencies:
rsvp "~3.2.1"

iconv-lite@^0.4.4:
version "0.4.23"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63"
Expand Down Expand Up @@ -1083,6 +1096,10 @@ mkdirp@^0.5.0, mkdirp@^0.5.1:
dependencies:
minimist "0.0.8"

mktemp@~0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/mktemp/-/mktemp-0.4.0.tgz#6d0515611c8a8c84e484aa2000129b98e981ff0b"

mocha@~1.17.1:
version "1.17.1"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-1.17.1.tgz#7f7671d68526d074b7bae660c9099f87e0ea1ccb"
Expand Down Expand Up @@ -1309,6 +1326,14 @@ progress@^1.1.8:
version "1.1.8"
resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"

quick-temp@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/quick-temp/-/quick-temp-0.1.8.tgz#bab02a242ab8fb0dd758a3c9776b32f9a5d94408"
dependencies:
mktemp "~0.4.0"
rimraf "^2.5.4"
underscore.string "~3.3.4"

rc@^1.2.7:
version "1.2.8"
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
Expand Down Expand Up @@ -1395,7 +1420,7 @@ ret@~0.1.10:
version "0.1.15"
resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"

rimraf@^2.2.8, rimraf@^2.6.1:
rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.1:
version "2.6.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
dependencies:
Expand All @@ -1409,6 +1434,14 @@ rsvp@^3.3.3:
version "3.6.2"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.6.2.tgz#2e96491599a96cde1b515d5674a8f7a91452926a"

rsvp@^4.7.0:
version "4.8.3"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.3.tgz#25d4b9fdd0f95e216eb5884d9b3767d3fbfbe2cd"

rsvp@~3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.2.1.tgz#07cb4a5df25add9e826ebc67dcc9fd89db27d84a"

run-async@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389"
Expand Down Expand Up @@ -1437,7 +1470,7 @@ sax@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"

semver@^5.3.0:
semver@^5.3.0, semver@^5.4.1:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"

Expand Down Expand Up @@ -1479,6 +1512,12 @@ signal-exit@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"

silent-error@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/silent-error/-/silent-error-1.1.0.tgz#2209706f1c850a9f1d10d0d840918b46f26e1bc9"
dependencies:
debug "^2.2.0"

[email protected]:
version "0.0.4"
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35"
Expand Down Expand Up @@ -1534,6 +1573,10 @@ split-string@^3.0.1, split-string@^3.0.2:
dependencies:
extend-shallow "^3.0.0"

sprintf-js@^1.0.3:
version "1.1.1"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.1.tgz#36be78320afe5801f6cea3ee78b6e5aab940ea0c"

sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
Expand Down Expand Up @@ -1663,6 +1706,13 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

underscore.string@~3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-3.3.4.tgz#2c2a3f9f83e64762fdc45e6ceac65142864213db"
dependencies:
sprintf-js "^1.0.3"
util-deprecate "^1.0.2"

union-value@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4"
Expand Down Expand Up @@ -1693,7 +1743,7 @@ user-home@^2.0.0:
dependencies:
os-homedir "^1.0.0"

util-deprecate@~1.0.1:
util-deprecate@^1.0.2, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"

Expand All @@ -1703,6 +1753,16 @@ walker@~1.0.5:
dependencies:
makeerror "1.0.x"

watch-detector@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/watch-detector/-/watch-detector-0.1.0.tgz#e37b410d149e2a8bf263a4f8b71e2f667633dbf8"
dependencies:
heimdalljs-logger "^0.1.9"
quick-temp "^0.1.8"
rsvp "^4.7.0"
semver "^5.4.1"
silent-error "^1.1.0"

watch@~0.18.0:
version "0.18.0"
resolved "https://registry.yarnpkg.com/watch/-/watch-0.18.0.tgz#28095476c6df7c90c963138990c0a5423eb4b986"
Expand Down