open-cli-tools / chokidar-cli

Fast cross-platform cli utility to watch file system changes
https://www.npmjs.com/package/chokidar-cli
MIT License
822 stars 51 forks source link

Ignored files shouldn't appear in the `Watching` output #27

Open mhkeller opened 8 years ago

mhkeller commented 8 years ago

Chokidar properly ignores files passed in through -i but the console text will still say it is watching these files. This appears to be the relevant code: https://github.com/kimmobrunfeldt/chokidar-cli/blob/89e1310d265c4d9dfe38ff0cc5458bdf3c36b32c/index.js#L170-L176

Edit by @kimmobrunfeldt: Made the link to explicitly state a commit instead of master branch.

kimmobrunfeldt commented 8 years ago

Do you have an example of the command and it's output?

mhkeller commented 8 years ago

Try it on here: https://github.com/mhkeller/chokidar-ignore

kimmobrunfeldt commented 8 years ago

Ok thanks. chokidar-cli is just logging all "patterns" which have been given to it for watching. In this case it seems like your terminal is doing an expansion for the pattern before chokidar-cli receives it and actually this command will be run: chokidar src/css/styles.styl src/js/main.js -i 'src/css/*.styl' -c 'npm start'

mhkeller commented 8 years ago

Ya that's what I figured L170-176 was doing. chokidar-cli would have to get the "patterns" minus the "ignored" files back from chokidar once it runs it through anymatch or whatever it is that tests against the ignored options. Could be impossible since it would rely on chokidar to send those back.

For now maybe a note in the readme would help? I spent a bit of time thinking my path was wrong before realizing it was actually ignoring as designed.

es128 commented 8 years ago

Chokidar has a .getWatched() method that could be invoked after the ready event is fired to inspect all the paths that are being observed, but I don't necessarily think that's the best solution here.

I'd suggest the confusion could be avoided by just expanding the message to echo back both user inputs:

console.error('Watching', '"' + watchlist + '" and ignoring "' + ignorelist + '" ..');
mhkeller commented 8 years ago

Ya that would certainly help.