smart-spawn

2.0.1 • Public • Published

smart-spawn

Spawn an async process and get back stdout, handling errors

Installation

npm install smart-spawn

Usage

var smartSpawn = require('smart-spawn');
 
var process = smartSpawn('ls', ['-l'], process.cwd(), function(err, stdout) {
    if (err) throw err;
 
    console.log(stdout);
}

Arguments

Arguments are, in order: the name of the process to spawn, arguments passed to the subprocess, the subprocess' working directory, and a callback function.

The callback receives two arguments. The first is an Error object which is passed if the process couldn't be spawned or if it exited with a nonzero exit code, otherwise it's undefined. The second is the process' stdout upon its completion (regardless of any errors that may have occured).

Return value

smart-spawn will return an instance of ChildProcess representing the spawned subprocess.

License

LGPL 3.0+

Author

Alex Jordan alex@strugee.net

Readme

Keywords

Package Sidebar

Install

npm i smart-spawn

Weekly Downloads

2

Version

2.0.1

License

LGPL-3.0+

Last publish

Collaborators

  • strugee