Spawn processes the way the npm cli likes to do. Give it some options, it'll give you a Promise that resolves or rejects based on the results of the execution.
Note: When the current user is root, this will use
infer-owner to find the owner of the current
working directory, and run with that effective uid/gid. Otherwise, it runs
as the current user always. (This helps prevent doing git checkouts and
such, and leaving root-owned files lying around in user-owned locations.)
const promiseSpawn =
promiseSpawn(cmd, args, opts, extra) ->
Run the command, return a Promise that resolves/rejects based on the process result.
Result or error will be decorated with the properties in the
object. You can use this to attach some helpful info about why the
command is being run, if it makes sense for your use case.
stdio is set to anything other than
'inherit', then the result/error
will be decorated with
stderr values. If
true, these will be strings. Otherwise they will be Buffer
Returned promise is decorated with the
stdin stream if the process is set
to pipe from
stdin. Writing to this stream writes to the
stdin of the
false. Return stdout/stderr output as strings rather than buffers.
process.cwd(). Current working directory for running the script. Also the argument to
infer-ownerto determine effective uid/gid when run as root on Unix systems.
- Any other options for
child_process.spawncan be passed as well, but note that
gidwill be overridden by the owner of the cwd when run as root on Unix systems, or