admin管理员组文章数量:1022476
I'm working on a node script that will do some stuff with execa
package.
Basically I want that script to change directory to certain path and then run another mand within that path.
I did it like that:
execamand('cd /some/dir && pwd');
But pwd
mand won't execute for some reason, though it finishes successfully.
What could be the reason, the mand after &&
won't execute, and is there any other way to manage that task?
Thanks!
I'm working on a node script that will do some stuff with execa
package.
Basically I want that script to change directory to certain path and then run another mand within that path.
I did it like that:
execa.mand('cd /some/dir && pwd');
But pwd
mand won't execute for some reason, though it finishes successfully.
What could be the reason, the mand after &&
won't execute, and is there any other way to manage that task?
Thanks!
Share Improve this question asked Feb 11, 2020 at 17:59 abstractmindabstractmind 10710 bronze badges 1-
2
docs say: "The shell option must be used if the mand uses shell-specific features, as opposed to being a simple file followed by its arguments." I'm guessing
&&
might be considered a shell-specific feature? – David784 Commented Feb 11, 2020 at 18:05
1 Answer
Reset to default 8The question you should be asking is "How do I run a mand with a different working directory?", which will give you the simple, robust, cross-platform solution of using the cwd
option:
execa.mand('pwd', { cwd: '/some/dir' });
If you instead want to acplish this task with &&
, you can do that by invoking a shell. This is more fragile and platform specific:
execa('sh', ['-c', 'cd /some/dir && pwd']);
I'm working on a node script that will do some stuff with execa
package.
Basically I want that script to change directory to certain path and then run another mand within that path.
I did it like that:
execamand('cd /some/dir && pwd');
But pwd
mand won't execute for some reason, though it finishes successfully.
What could be the reason, the mand after &&
won't execute, and is there any other way to manage that task?
Thanks!
I'm working on a node script that will do some stuff with execa
package.
Basically I want that script to change directory to certain path and then run another mand within that path.
I did it like that:
execa.mand('cd /some/dir && pwd');
But pwd
mand won't execute for some reason, though it finishes successfully.
What could be the reason, the mand after &&
won't execute, and is there any other way to manage that task?
Thanks!
Share Improve this question asked Feb 11, 2020 at 17:59 abstractmindabstractmind 10710 bronze badges 1-
2
docs say: "The shell option must be used if the mand uses shell-specific features, as opposed to being a simple file followed by its arguments." I'm guessing
&&
might be considered a shell-specific feature? – David784 Commented Feb 11, 2020 at 18:05
1 Answer
Reset to default 8The question you should be asking is "How do I run a mand with a different working directory?", which will give you the simple, robust, cross-platform solution of using the cwd
option:
execa.mand('pwd', { cwd: '/some/dir' });
If you instead want to acplish this task with &&
, you can do that by invoking a shell. This is more fragile and platform specific:
execa('sh', ['-c', 'cd /some/dir && pwd']);
本文标签: javascriptHow do I execute a seria of commands with execaStack Overflow
版权声明:本文标题:javascript - How do I execute a seria of commands with execa? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745519119a2154232.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论