|
@ -10,8 +10,15 @@ var spawn = exports.spawn = function (path, args, env) { |
|
|
return child; |
|
|
return child; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
exports.exec = function (command /*, options, callback */) { |
|
|
|
|
|
if (arguments.length < 3) { |
|
|
|
|
|
return exports.execFile("/bin/sh", ["-c", command], arguments[1]); |
|
|
|
|
|
} else { |
|
|
|
|
|
return exports.execFile("/bin/sh", ["-c", command], arguments[1], arguments[2]); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
exports.exec = function (command /* , options, callback */) { |
|
|
exports.execFile = function (file, args /*, options, callback */) { |
|
|
var options = { encoding: 'utf8' |
|
|
var options = { encoding: 'utf8' |
|
|
, timeout: 0 |
|
|
, timeout: 0 |
|
|
, maxBuffer: 200*1024 |
|
|
, maxBuffer: 200*1024 |
|
@ -19,15 +26,16 @@ exports.exec = function (command /* , options, callback */) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var callback = arguments[arguments.length-1]; |
|
|
var callback = arguments[arguments.length-1]; |
|
|
if (typeof arguments[1] == 'object') { |
|
|
|
|
|
|
|
|
if (typeof arguments[2] == 'object') { |
|
|
var keys = Object.keys(options); |
|
|
var keys = Object.keys(options); |
|
|
for (var i = 0; i < keys.length; i++) { |
|
|
for (var i = 0; i < keys.length; i++) { |
|
|
var k = keys[i]; |
|
|
var k = keys[i]; |
|
|
if (arguments[1][k] !== undefined) options[k] = arguments[1][k]; |
|
|
if (arguments[2][k] !== undefined) options[k] = arguments[2][k]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var child = spawn("/bin/sh", ["-c", command]); |
|
|
var child = spawn(file, args); |
|
|
var stdout = ""; |
|
|
var stdout = ""; |
|
|
var stderr = ""; |
|
|
var stderr = ""; |
|
|
var killed = false; |
|
|
var killed = false; |
|
|