Skip to content

mariocasciaro/spawned

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM version Build Status Coverage Status Dependency Status

spawned

Smart wrapper around child_process.spawn using promises.

Usage

var spawned = require('spawned');
spawned('echo', ['test'])
  .then(function(proc) {
    console.log("Did it work? " + ((proc.out.match(/test/))? "yes" : "no"));
  })
  .catch(function(err) {
    console.log("Boooooom");
    console.error(err.err);
  });

API

spawn(command, [args], [options])

Spawn a new process and returns a promise.

  • command: String the command to execute
  • args: Array a list of arguments to pass to the command
  • options: Object inherits the options from child_process.spawn plus these:
    • out: A WriteableStream receiving the stdout data
    • err: A WriteableStream receiving the stderr data

Returns a promise which:

  • when fullfilled resolves to an object like:
    • err: String containing stderr
    • out: String containig stdout
    • combined: String containing the intermingled contents of stdout and stderr
    • code: Number the return code of the program
  • when rejected resolves to an Error having the same properties as above.

About

Smart wrapper around child_process.spawn using promises

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published