Package Exports
- async-exec-cmd
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (async-exec-cmd) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Simple, fast, flexible and cross-platform async executing commands (with node-cross-spawn)
Install
npm i --save async-exec-cmd
npm testAPI
For more use-cases see the tests
asyncExecCmd
Async execute command via spawn. All arguments are rebuilt, merged, structured, normalized and after all passed to cross-spawn, which actually is Node's
spawn.
<cmd>{String}[args]{Array}[opts]{Object}<callback>{Function}returns{Stream} actually whatchild_process.spawnreturns
Example:
var asyncExecCmd = require('async-exec-cmd');
var cp = asyncExecCmd('npm install', [
'--save-dev', 'bluebird'
], function __cb(err, res) {
// res[0] is status code
if (err || res[0] > 0) {
console.error(err);
return;
}
// res[1] is actual result
console.log(res[1]);
};);Possible signatures (will work)
these examples should work without problems
var cmd = require('async-exec-cmd');
function __cb(err, res) {
// res[0] is status code
if (err || res[0] > 0) {
console.error(err);
return;
}
// res[1] is actual result
console.log(res[1]);
}
cmd('npm', __cb);
cmd('npm', {someFake: 'options'}, __cb);
cmd('npm', ['install', '--save-dev', 'bluebird'], __cb);
cmd('npm', ['install', '--save-dev', 'bluebird'], {stdio: [null, null, null]}, __cb);
cmd('npm -v', __cb)
cmd('npm install', ['--save-dev', 'bluebird'], __cb);
cmd('npm install', ['--save-dev', 'bluebird'], {stdio: [null, null, null]}, __cb);
cmd('npm -v', {stdio: [null, null, null]}, __cb);Impossible signatures (will throws/errors)
these examples should not work
cmd(__cb);
//=> first argument cant be function
cmd({ok:true});
//=> should have `callback` (non empty callback)
cmd(['--save-dev', 'bluebird']);
//=> should have `callback` (non empty callback)
cmd(['--save-dev', 'bluebird'], {ok:true});
//=> should have `callback` (non empty callback)
cmd({ok:true}, __cb);
//=> expect `cmd` be string
cmd(['--save-dev', 'bluebird'], __cb);
//=> expect `cmd` be string
cmd(['--save-dev', 'bluebird'], {ok:true}, __cb);
//=> expect `cmd` be stringAuthor
Charlike Mike Reagent
License 
Copyright (c) 2015 Charlike Mike Reagent, contributors.
Released under the MIT license.
Powered and automated by kdf, January 26, 2015