Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --interval parameter to specify the polling interval for directory/file changes. #84

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 4 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var execshell = require('exec-sh')
var watch = require('./main.js')

if(argv._.length === 0) {
console.error('Usage: watch <command> [...directory] [--wait=<seconds>] [--ignoreDotFiles] [--ignoreUnreadable]')
console.error('Usage: watch <command> [...directory] [--wait=<seconds>] [--interval=<seconds>] [--ignoreDotFiles] [--ignoreUnreadable]')
process.exit()
}

Expand All @@ -24,6 +24,9 @@ if (argLen > 1) {
}

var waitTime = Number(argv.wait || argv.w)
if (argv.interval || argv.i) {
watchTreeOpts.interval = Number(argv.interval || argv.i) * 1000.0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested default of 0.1s (node default is 5.007s!):

watchTreeOpts.interval = Number(argv.interval || argv.i || 0.1) * 1000.0;

}

if(argv.ignoreDotFiles || argv.d)
watchTreeOpts.ignoreDotFiles = true
Expand Down
4 changes: 4 additions & 0 deletions readme.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The first argument is the directory root you want to watch.

The options object is passed to fs.watchFile but can also be used to provide two additional watchTree specific options:

* `'interval' - Specifies the interval duration in milliseconds, the time period between polling for file changes.
* `'ignoreDotFiles'` - When true this option means that when the file tree is walked it will ignore files that being with "."
* `'filter'` - You can use this option to provide a function that returns true or false for each file and directory to decide whether or not that file/directory is included in the watcher.
* `'ignoreUnreadableDir'` - When true, this options means that when a file can't be read, this file is silently skipped.
Expand Down Expand Up @@ -95,6 +96,9 @@ OPTIONS:
after running <command>. Setting this option will
throttle calls to <command> for the specified duration.

--interval=<seconds>
Specifies the interval duration in seconds, the time period between polling for file changes.

--ignoreDotFiles, -d
Ignores dot or hidden files in the watch [directory].

Expand Down