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
child_process.execSync should return object with std of plain stdout #35125
Comments
|
I think this might be a good idea, which allows example: const { stdout, stderr, status } = cp.execSync('xxx', { skipThrow: true }) |
|
@himself65 Sounds as a good compromise. With this flag the behaviour will be similar to |
|
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
|
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
|
Leaving a comment because this would still be a useful feature! In my case, I'm building out a test suite for an npm package that runs from the command line, and it's nice being able to run my happy path integration tests with But I can't do the same for my sad path integration tests; the same code will just throw error |
Is your feature request related to a problem? Please describe.
I wanted to run sequentially a series of processes and check their exit code and stderr to make a decision whether the run command failed or not. In my case exit code=0 and anything in stderr having
warningsubstring should be considered as fail.When I needed to run just one command I happily used the following code:
When the task changed and I needed to run few commands in a row I decided to use synchronous version of that method:
However using that code I can't check stderr when no exception is thrown.
Describe the solution you'd like
I'd like
childProcess.execSyncto return an object containingstatus/code,stderr,stdoutand other fields similar to returned object inchild_process.spawnSync(https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options):Describe alternatives you've considered
Alternatives:
childProcess.exec) and rewrite the code to work in asynchronous mannerchildProcess.spawnSyncwithshell=trueThe text was updated successfully, but these errors were encountered: