diff --git a/README.md b/README.md index 1448d47..2b9a886 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ options: * `glob`: a single string glob pattern or an array of them. * `poll`: puts the watcher in polling mode. Under the hood that means `fs.watchFile`. * `watchman`: makes the watcher use [watchman](https://facebook.github.io/watchman/). +* `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. @@ -91,7 +92,7 @@ All events are passed the file/dir path relative to the root directory This module includes a simple command line interface, which you can install with `npm install sane -g`. ``` -Usage: sane [...directory] [--glob=] [--poll] [--watchman] [--dot] [--wait=] +Usage: sane [...directory] [--glob=] [--poll] [--watchman] [--watchman-path=] [--dot] [--wait=] OPTIONS: --glob= @@ -106,6 +107,9 @@ OPTIONS: --watchman, -w Use watchman (if available). + --watchman-path= + Sets a custom path for watchman binary (if using this mode). + --dot, -d Enables watching files/directories that start with a dot. diff --git a/src/cli.js b/src/cli.js index 125bd6d..bc8970d 100755 --- a/src/cli.js +++ b/src/cli.js @@ -8,7 +8,7 @@ var execshell = require('exec-sh'); if (argv._.length === 0) { var msg = 'Usage: sane [...directory] [--glob=] ' + - '[--ignored=] [--poll] [--watchman] [--dot] ' + + '[--ignored=] [--poll] [--watchman] [--watchman-path=] [--dot] ' + '[--wait=]'; console.error(msg); process.exit(); @@ -23,6 +23,7 @@ var glob = argv.glob || argv.g; var ignored = argv.ignored || argv.i; var poll = argv.poll || argv.p; var watchman = argv.watchman || argv.w; +var watchmanPath = argv['watchman-path']; if (dot) { opts.dot = true; @@ -39,6 +40,9 @@ if (poll) { if (watchman) { opts.watchman = true; } +if (watchmanPath) { + opts.watchmanPath = watchmanPath; +} var wait = false; var watcher = sane(dir, opts); diff --git a/src/common.js b/src/common.js index 573cad3..899b88c 100644 --- a/src/common.js +++ b/src/common.js @@ -41,6 +41,11 @@ exports.assignOptions = function(watcher, opts) { : function() { return false; }; + + if (opts.watchman && opts.watchmanPath) { + watcher.watchmanPath = opts.watchmanPath; + } + return opts; }; diff --git a/src/watchman_watcher.js b/src/watchman_watcher.js index 75842bf..2458307 100644 --- a/src/watchman_watcher.js +++ b/src/watchman_watcher.js @@ -53,7 +53,9 @@ WatchmanWatcher.prototype.init = function() { } var self = this; - this.client = new watchman.Client(); + this.client = new watchman.Client( + this.watchmanPath ? { watchmanBinaryPath: this.watchmanPath } : {} + ); this.client.on('error', function(error) { self.emit('error', error); });