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 verbose command line option to print a message everytime the co… #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var path = require('path')
var watch = require('./main.js')

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

Expand Down Expand Up @@ -47,14 +47,26 @@ var dirLen = dirs.length
var skip = dirLen - 1
for(i = 0; i < dirLen; i++) {
var dir = dirs[i]
console.error('> Watching', dir)
console.error('> watch: Watching', dir)
watch.watchTree(dir, watchTreeOpts, function (f, curr, prev) {
if(skip) {
skip--
return
}
if(wait) return

if (argv.verbose || argv.v) {
if (typeof f == "object" && prev === null && curr === null) {
console.log("> watch: Watching " + Object.keys(f).length + " files.");
} else if (prev === null) {
console.log("> watch: New file: " + f + ". Executing.");
} else if (curr.nlink === 0) {
// f was removed
console.log("> watch: File removed: " + f + ". Executing.");
} else {
console.log("> watch: File changed: " + f + ". Executing");
}
}
execshell(command)

if(waitTime > 0) {
Expand Down