https://github.com/aleclarson/exec
Easy shell execution
https://github.com/aleclarson/exec
child-process exec nodejs shell
Last synced: 2 months ago
JSON representation
Easy shell execution
- Host: GitHub
- URL: https://github.com/aleclarson/exec
- Owner: aleclarson
- License: mit
- Created: 2016-05-02T08:10:41.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-06-29T20:28:53.000Z (about 4 years ago)
- Last Synced: 2025-12-26T16:43:55.767Z (6 months ago)
- Topics: child-process, exec, nodejs, shell
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @cush/exec
Easy shell execution
```js
const exec = require('@cush/exec');
// Sync version
try {
const stdout = exec.sync('npm root -g');
console.log(stdout);
} catch(stderr) {
console.error(stderr);
}
// Async version
exec('git status --porcelain')
.then(stdout => {
console.log(stdout);
}, stderr => {
console.error(stderr);
});
// Child process options
const files = await exec('ls -a', {
cwd: 'path/to/dir'
});
// Additional arguments
const status = await exec('git status', [
porcelain ? '--porcelain' : null, // null and undefined values are filtered out
]);
```
Available options are described [here](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback).
### Notes
- An error is thrown (or the promise is rejected) whenever the exit code of the child process is non-zero.