Skip to content

Commit 59e6621

Browse files
Benjamin Haineswatilde
authored andcommitted
Add --poll flag
Use polling to monitor for changes. Omitting the interval will default to 100ms. This option is useful if you're watching an NFS volume.
1 parent 2d9c50f commit 59e6621

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ var argv = require("yargs")
3030
.describe('s', 'Alternative input syntax parser')
3131
.alias('p', 'parser')
3232
.describe('p', 'Alternative CSS parser')
33+
.option('poll', {
34+
describe: 'Use polling to monitor for changes.',
35+
default: false,
36+
})
3337
.alias('t', 'stringifier')
3438
.describe('t', 'Alternative output stringifier')
3539
.alias('w', 'watch')
@@ -146,8 +150,16 @@ async.forEach(inputFiles, compile, onError);
146150
function fsWatcher(entryPoints) {
147151
var watchedFiles = entryPoints;
148152
var index = {}; // source files by entry point
153+
var opts = {};
154+
155+
if (argv.poll) {
156+
opts.usePolling = true;
157+
}
158+
if (typeof argv.poll === 'number') {
159+
opts.interval = argv.poll;
160+
}
149161

150-
var watcher = require('chokidar').watch(watchedFiles);
162+
var watcher = require('chokidar').watch(watchedFiles, opts);
151163
// recompile if any watched file is modified
152164
// TODO: only recompile relevant entry point
153165
watcher.on('change', function() {

0 commit comments

Comments
 (0)