https://github.com/parro-it/spawn-shell
Run shell commands using child_process#spawn.
https://github.com/parro-it/spawn-shell
Last synced: 3 months ago
JSON representation
Run shell commands using child_process#spawn.
- Host: GitHub
- URL: https://github.com/parro-it/spawn-shell
- Owner: parro-it
- License: mit
- Created: 2016-01-27T22:42:07.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:19:53.000Z (over 5 years ago)
- Last Synced: 2025-09-19T23:38:05.137Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.99 MB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# spawn-shell
[](https://greenkeeper.io/)
[](http://travis-ci.org/parro-it/spawn-shell)
[](https://npmjs.org/package/spawn-shell)
[](https://npmjs.org/package/spawn-shell)
> Run shell commands using child_process#spawn.
# Features
* Multi-platform - run on OSX, Linux, Windows
* Return a promise that resolve with exitcode when spawned process terminetes
* Use `child_process#spawn` for greater flexibility than `child_process#exec`
* Use user system shell by default, or customize it via `shell` option.
* Inject your package `node_modules/.bin` directory in path.
* `stdio` spawn option defaults to `inherit`, sharing parent process stdin & stdout
# Installation
```bash
npm install --save spawn-shell
```
# Usage
```javascript
const spawnShell = require('spawn-shell');
// simple to use with promise
const exitCode = await spawnShell('echo "it works" && exit 42').exitPromise;
// output `it works` to stdout
// exitCode === 42
// access ChildProcess instance before promise is resolved
const p = spawnShell('echo "it works"', {
stdio: [0, 'pipe', 2]
});
p.stdout.pipe(concat(
{encoding: 'string'},
output => {
// output === 'it works'
}
));
```
# License
The MIT License (MIT)
Copyright (c) 2017 parro-it