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

Glob expansion in --command #8

Closed
jareware opened this issue Jul 21, 2015 · 6 comments
Closed

Glob expansion in --command #8

jareware opened this issue Jul 21, 2015 · 6 comments

Comments

@jareware
Copy link

Thanks for your work on the project, it's been really useful!

One hitch I ran into lately was that run doesn't spawn a shell, so when you compare:

$ cat *.js

with

$ chokidar . --command "cat *.js"

the results may not be what you expect.

I'm working around that with a simple --command "cat $(ls *.js)", but it looks a bit... silly.

@jareware
Copy link
Author

Oh, also, the silly workaround obviously won't expand the glob again when the command is re-invoked.

@kimmobrunfeldt
Copy link
Collaborator

Yeah this is an annoying problem, the current workaround is to move your commands to a .sh script or to a separate npm scripts task. So in other words, to delegate the shell magic to other tools like npm or bash. Related to this issue: https://github.com/kimmobrunfeldt/chokidar-cli/issues/6

I would like to fix this so that this library would also support the basic shell features like globbing etc. Do you know some library which would correctly support these bash features? I need to get streaming stdout and stderr of the spawned processes so that the output can be correctly printed. That's why I ended up using spawn function.

@jareware
Copy link
Author

Can you just spawn an instance of whatever's at process.env.SHELL, feed it the command, and let it worry about the whole thing?

I think the expectation invariably is that if you can run some command in your shell, putting the same command into --command should yield the same results.

@kimmobrunfeldt
Copy link
Collaborator

That sounds like a good approach, I'll try at some point

@kimmobrunfeldt
Copy link
Collaborator

Just writing this down so I won't forget: whatever the solution will be - it has to work on windows too since I'm promising cross platform support.

@kimmobrunfeldt
Copy link
Collaborator

Fix released in 1.0.1. Now the system's shell is taken from environment variable. See the solution here: https://github.com/kimmobrunfeldt/chokidar-cli/blob/master/utils.js#L6

Does this seem robust enough @jareware? I tested it with Windows 8, Ubuntu 12.04 and OS X 10.9.5. I didn't find good documentation of what would be the best env variable to find out the shell path in Windows.

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

No branches or pull requests

2 participants