Skip to content
Merged
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
15 changes: 14 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ var path = require('path')
var watch = require('./main.js')

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

Expand Down Expand Up @@ -35,6 +43,11 @@ if(argv.ignoreDotFiles || argv.d)
if(argv.ignoreUnreadable || argv.u)
watchTreeOpts.ignoreUnreadableDir = true

if(argv.ignoreDirectoryPattern || argv.p) {
var match = (argv.ignoreDirectoryPattern || argv.p).match(/^\/(.*)\/([gimuy])$/);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

#99 adds minimatch for matching, we should consider staying consistent.

watchTreeOpts.ignoreDirectoryPattern = new RegExp(match[1], match[2])
}

if(argv.filter || argv.f) {
try {
watchTreeOpts.filter = require(path.resolve(process.cwd(), argv.filter || argv.f))
Expand Down
4 changes: 4 additions & 0 deletions readme.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ OPTIONS:
--ignoreUnreadable, -u
Silently ignores files that cannot be read within the
watch [directory].

--ignoreDirectoryPattern=<regexp>, -p
Silently skips directories that match the regular
expression.
```

It will watch the given directories (defaults to the current working directory) with `watchTree` and run the given command every time a file changes.
Expand Down