parallelshell icon indicating copy to clipboard operation
parallelshell copied to clipboard

Ability to set CWD

Open barrysteyn opened this issue 10 years ago • 6 comments

Hi Keith

Inspired by your blog post about scrapping grunt etc, and just using NPM, I happily using parallelshell. Unfortunately, there are many cases where I need to set the current working directory (CWD) to run the command in. Now that we are using exec, cd does not work. So I have come up with my own solution, which is to pass parallelshell a JSON array, and if it parses and if it contains two items, the first item will be the CWD. If any of those conditions do not hold, then just use as per normal.

barrysteyn avatar Sep 21 '15 18:09 barrysteyn

@barrysteyn could you try checking out #30 and seeing if that works without your changes. #30 is the direction we want to be going in.

keithamus avatar Sep 21 '15 20:09 keithamus

Hi @keithamus. From just looking at #30, I think it should be able to do what I need. But I am still of the opinion that one should be able to set the CWD. The way I have done it is a little inelegant for the user. I have not tested #30, but I still advise that there should be some way to set the CWD.

barrysteyn avatar Sep 21 '15 21:09 barrysteyn

I don't think it's necessary to set the cwd provided we're spawning shells. I'll agree that the current implementation is broken, but if we merge #30 then you can just do one of the following:

cd /some/folder && parallelshell 'some command'
parallelshell 'cd /some/folder && some command'

keithamus avatar Sep 21 '15 21:09 keithamus

@keithamus When do you plan to merge #30 ? I also need this feature)

Jokero avatar Sep 02 '17 15:09 Jokero

@Jokero I can give it a try and see if it works correctly, then I'll merge :)

darkguy2008 avatar Sep 02 '17 19:09 darkguy2008

Cool, thank you

Jokero avatar Sep 02 '17 23:09 Jokero