package
Flexible spawn() with exec() syntax.
npm install spawnxGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Estimated unpacked size across 1 packages.
5.1 kB
Includes dependencies.
Flexible spawn() with exec() syntax.
npm install spawnxspawnx(command, [options,] callback);var run = require('spawnx');
run('/path/to/command --foo bar 1', function(err, stdout, stderr) {
console.log(err || stdout);
})
// let's pipe the output from the command to a log file as it comes.
var stream = fs.createWriteStream('output.log');
run('another_command --test', { cwd: '/tmp', stdout: stream }, function(err) {
console.log('Finished');
stream.close();
})Whatever options you pass in the options argument will be passed to the actual
spawn() call. There are two additional options that you may pass: stdout and
stderr. If present, spawnx will pipe the output from the spawn command to
those streams. That way you can have live output of a running command.
Also important: the path to command may be relative, in which case the full
path is looked for by searching the environment's $PATH. If now options.cwd is
set, the command's dirname is set as the cwd for the spawn call.
Written by Tomás Pollak.
(c) Fork Ltd. MIT license.