Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steelbrain/exec
Node's Process spawning APIs beautified
https://github.com/steelbrain/exec
Last synced: 11 days ago
JSON representation
Node's Process spawning APIs beautified
- Host: GitHub
- URL: https://github.com/steelbrain/exec
- Owner: steelbrain
- License: mit
- Created: 2016-02-27T19:42:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-02T16:39:50.000Z (over 1 year ago)
- Last Synced: 2024-09-09T17:11:54.354Z (2 months ago)
- Language: JavaScript
- Size: 933 KB
- Stars: 9
- Watchers: 4
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Exec
[![Greenkeeper badge](https://badges.greenkeeper.io/steelbrain/exec.svg)](https://greenkeeper.io/)
Node's Process spawning APIs beautified
## Installation
```sh
npm install --save sb-exec
```## API
```js
type $OptionsAccepted = {
timeout?: number | Infinity, // In milliseconds
stream?: 'stdout' | 'stderr' | 'both',
env: Object,
stdin?: string | Buffer,
local?: {
directory: string,
prepend?: boolean
},
throwOnStderr?: boolean = true,
allowEmptyStderr?: boolean = false,
ignoreExitCode?: boolean
} // Also supports all options of child_process::spawntype PromisedProcess = {
then(callback: Function): Promise
catch(callback: Function): Promise
kill(signal: number)
}export function exec(filePath: string, parameters: array, options: $OptionsAccepted): PromisedProcess
export function execNode(filePath: string, parameters: array, options: $OptionsAccepted): PromisedProcess
```## Explanation
### Promise callbacks
* `then` callback is supposed to accept one of these results, depending on `options.stream`:
* `stdout` and `stderr` will result in a string, representing an stdout or stderr stream, respectively.
* `both` will result in an object of `{stdout, stderr, exitCode}` representing their respective streams and an exit code of a process.
* If `options.stream` is not provided it is assumed to be `stdout`, so a promise will result in a string representing an stdout stream.### `options.local`
`options.local` adds node executables in `node_modules` relative to
`options.local.directory` to `PATH` like in npm scripts.`options.local.prepend` prioritizes local executables over ones already in `PATH`.
## License
This project is licensed under the terms of MIT License, see the LICENSE file
for more info