зеркало из https://github.com/microsoft/shelljs.git
Merge remote-tracking branch 'iapain/exec-options-fix'
Conflicts: shell.js
This commit is contained in:
Коммит
f7d2e3c188
6
shell.js
6
shell.js
|
@ -1095,11 +1095,17 @@ function _exec(command, options, callback) {
|
|||
if (!command)
|
||||
error('must specify command');
|
||||
|
||||
// Callback is defined instead of options.
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = { async: true };
|
||||
}
|
||||
|
||||
// Callback is defined with options.
|
||||
if (typeof options === 'object' && typeof callback === 'function') {
|
||||
options.async = true;
|
||||
}
|
||||
|
||||
options = extend({
|
||||
silent: config.silent,
|
||||
async: false
|
||||
|
|
11
test/exec.js
11
test/exec.js
|
@ -91,7 +91,16 @@ shell.exec('node -e \"console.log(5678);\"', function(code, output) {
|
|||
assert.equal(code, 0);
|
||||
assert.ok(output === '5566\n' || output === '5566\nundefined\n'); // 'undefined' for v0.4
|
||||
|
||||
shell.exit(123);
|
||||
//
|
||||
// callback as 3rd argument (slient:true)
|
||||
//
|
||||
shell.exec('node -e \"console.log(5678);\"', {silent:true}, function(code, output) {
|
||||
assert.equal(code, 0);
|
||||
assert.ok(output === '5678\n' || output === '5678\nundefined\n'); // 'undefined' for v0.4
|
||||
|
||||
shell.exit(123);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче