Skip to content

Inject changed file into command#8

Merged
caseywebdev merged 1 commit intocaseywebdev:masterfrom
remy:master
Nov 13, 2014
Merged

Inject changed file into command#8
caseywebdev merged 1 commit intocaseywebdev:masterfrom
remy:master

Conversation

@remy
Copy link
Copy Markdown
Contributor

@remy remy commented Nov 13, 2014

Allows users to programmatically use $FILE (or $EVENT) in their commands.

Such as:

watchy -w lib -- say "\$FILE changed"

Note that we escape the $FILE env value otherwise it gets evaluated immediately.

(Please excuse the typo in the actual commit, and the unsolicited PR!)

Allows users to programatically use $FILE (or $EVENT) in their commands.

Such as:

```
watchy -w lib -- say "\$FILE changed"
```

Note that we escape the $FILE env value otherwise it gets evaluated immediately.
@remy
Copy link
Copy Markdown
Contributor Author

remy commented Nov 13, 2014

It also means you can do things like this:

watchy -w styles -- "lessc \$FILE | autoprefixer -o .tmp/styles/\${\$(basename \$FILE)%.*}.css"

Which might look a little nuts, but can take the .less file that actually changed and then only process that changed file.

@caseywebdev
Copy link
Copy Markdown
Owner

This already works, no?

~ FOO=bar watchy -w . -- 'echo $FOO'
[watchy] echo $FOO Spawning...
bar
[watchy] echo $FOO Exited cleanly

@remy
Copy link
Copy Markdown
Contributor Author

remy commented Nov 13, 2014

No, $FOO is a static env value that you're setting when you run watchy for the first time.

What $FILE is, is the full path of the file that triggered the event (that Chokidar passes to your all event handler). So this $FILE value will change depending on what caused the change.

@caseywebdev
Copy link
Copy Markdown
Owner

Ahh, I see what you mean. That sounds like a nice feature, thanks!

caseywebdev added a commit that referenced this pull request Nov 13, 2014
Inject changed file into command
@caseywebdev caseywebdev merged commit baf3631 into caseywebdev:master Nov 13, 2014
@tschaub
Copy link
Copy Markdown
Contributor

tschaub commented Nov 18, 2014

I'm seeing a failure with 0.5.5 that goes away when downgrading to 0.5.4:

env: node: No such file or directory

I'm running watchy as part of a Makefile target that essentially looks like this:

watchy --watch src -- make dist

And the dist target runs browserify. Everything works at 0.5.4. When I include this change, the task fails. I'll dig a bit more to see if I can come up with a simpler test case.

Comment thread lib/pheonix.js
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you want to copy everything from process.env first (and then add your EVENT and FILE - ideally only if they don't already exist).

@tschaub
Copy link
Copy Markdown
Contributor

tschaub commented Nov 18, 2014

Proposed fix in #9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants