Package Exports
- spawn-stack
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (spawn-stack) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
spawn-stack
Spawn a new process using stack
command with the given arguments
const spawnStack = require('spawn-stack');
spawnStack(['--version']).then(result => {
result.output; //=> 'Version 1.3.2 x86_64 hpack-0.15.0'
});
Installation
Make sure stack
command is installed in your $PATH
, then install spawn-stack
via npm CLI.
npm install spawn-stack
API
const spawnStack = require('spawn-stack');
spawnStack(args [, options])
args: Array<String>
(command line arguments passed to stack
command)
options: Object
(execa
options, with preferLocal
defaulting to false
)
Return: ChildProcess
It returns the same value as execa
's:
a
child_process
instance, which is enhanced to also be aPromise
for a resultObject
withstdout
andstderr
properties.
The return value also has Symbol.observable
method that returns a zen-observable instance passing each line of stderr
to its Subscription
. That means you can convert the return value into an Observable
by using Observable.from
.
const Observable = require('zen-observable');
const spawnStack = require('spawn-stack');
const cp = spawnStack(['setup', '8.0.2']);
Observable.from(cp).subscribe({
next(line) {
console.log(line);
// stack will use a sandboxed GHC it installed ...
},
complete() {
console.log('Done.')
}
});
License
Copyright (c) 2017 Shinnosuke Watanabe
Licensed under the MIT License.