0.2.2 • Published 11 years ago
hatchling v0.2.2
Hatchling
Buffered spawn for node.
Example
var spawn = require('hatchling'),
timeout;
var child = spawn('ps', ['aux'], function(err, stdout) {
console.log(stdout);
clearTimeout(timeout);
});
timeout = setTimeout(child.kill, 1000); // kill it after a second if we dont hear back
// Example with invalid command options
spawn('ls', ['-aslkj'], function(err, stderr) {
console.log(err);
console.log(stderr);
});Reasoning
Spawn is awesome but sometimes you need a quick way to just get the output and go. Hatcling lets you pass in as many or as few arguments as you want. The structure is:
spawn(cmd, [args], [options], [cb])cmdis a string of the command to executeargsis an array of arguments passedoptsis an option which is standardprocess.spawnoptionscbis a function that takesfn(err, stderr/stdout). Iferris not null,stderrwill be given. Otherwise it isstdout. If a process exits with a non-zero status code, an error will be thrown.