-
Notifications
You must be signed in to change notification settings - Fork 744
Provide cwd option for exec.
#163
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
Conversation
|
+1 |
|
@taoyuan Thanks for submitting the PR! @taoyuan @oNaiPs What is the benefit of this PR vs. the following? cd('path/to/dir');
exec('git status');
cd('-'); // <- the "jump back" feature used here will be released in 6.x, but it's currently merged on masterThis has 3 lines of code, but it's very intuitive to a bash programmer. If there's an advantage to the |
|
If you want to use shelljs asynchronously, it makes things more difficult to manage. Would this even work? |
|
@oNaiPs I think it would look a bit like this, right? cd('path/to/dir1');
exec('git status', {async: true}); // executes asynchronously in directory 1
cd('-');
cd('path/to/dir2');
exec('git status', {async: true}); // executes asynchronously in directory 2
cd('-');Correct me if I'm missing something |
|
@nfischer: I think that this is a good idea. There are a whole host of reasons you might want to specify a |
|
@nfischer Yes. It works fine in most cases. But in some case, I want to exec command without change current directory, so I must wrap a function: funciton exec(..., opts) {
...
var owd = process.cwd();
if (opts.cwd) sh.cd(opts.cwd);
result = sh.exec(command, opts);
if (opts.cwd) sh.cd(owd);
}If we support sh.exec(command, opts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change in the comments. Run scripts/generate-docs.js to generate the README
|
@taoyuan Could you please rebase off master? We've had quite a few changes, and there are now merge conflicts. Also, please remove the section about I left a comment above that should be addressed. Also, please add a unit test to test the Edit: |
No description provided.