Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

each-exec

1.0.0 • Public • Published

each-exec

Build Status Build status Coverage Status Dependency Status devDependency Status

A Node module to run commands in parallel

var eachExec = require('each-exec');
 
eachExec(['echo "foo"', 'echo "bar"'], function(err, stdouts, stderrs) {
  if (err) {
    throw err;
  }
 
  stdouts; //=> ['foo\n', 'bar\n']
  stderrs; //=> ['', '']
});

Installation

NPM version

Use npm.

npm install each-exec

API

var eachExec = require('each-exec');

eachExec(commands [, options, callback])

commands: Array of String (the commands to run)
options: Object (child_process.exec options)
callback: Function

It runs the commands using child_process.exec in parallel.

After all the commands have finished, it runs the callback function.

When one of the commands fails, it immediately calls the callback function and the rest of the commands won't be run.

callback(error, stdoutArray, stderrArray)

error: Error if one of the commands fails, otherwise null
stdoutArray: Array of String (stdout of the commands)
stderrArray: Array of String (stderr of the commands)

It doesn't pass any values to the second argument and third argument, if one of the commands fails.

execSeries([
  'echo foo',
  'exit 200',
  'echo bar'
], function(err, stdouts, stderrs) {
  err.code; //=> 200
  stdouts; //=> undefined
  stderrs; //=> undefined
  arguments.length; //=> 1
});

Callback function is optional.

execSeries(['mkdir foo', 'mkdir bar']);
 
setTimeout(function() {
  fs.existsSync('foo'); //=> true
  fs.existsSync('bar'); //=> true
}, 1000);

License

Copyright (c) 2014 Shinnosuke Watanabe

Licensed under the MIT License.

install

npm i each-exec

Downloadsweekly downloads

2

version

1.0.0

license

none

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability