doowb / watch-cli

Watch files and execute an npm script when files change.
MIT License
60 stars 10 forks source link

command variables #2

Closed jmcbee closed 6 years ago

jmcbee commented 9 years ago

How do I detect in my command which file has changed?

doowb commented 9 years ago

watch-cli doesn't pass anything to the command. If you have any ideas on how that would work, I'd be interested in seeing them.

jmcbee commented 9 years ago

maybe setting an environment variable as the command gets called.

thomasfl commented 7 years ago

My pull request solves this problem by making the environment variables FILENAME, EVENT and ABSOLUTE_FILENAME available in the command:

Linux/macOS:

$ watch -p '**/*.js' -c 'jshint $FILENAME'

In Windows:

> watch -p "**/*.js" -c "jshint %FILENAME%"
doowb commented 6 years ago

Closing since this was released in 0.2.3. Thanks @thomasfl for the PR: #8

thomasfl commented 6 years ago

You’re welcome Brian. :-)