Comparing version 0.2.22 to 0.2.23
@@ -20,6 +20,2 @@ /* | ||
/** | ||
@name jake | ||
@namespace jake | ||
*/ | ||
var api = new (function () { | ||
@@ -36,3 +32,3 @@ /** | ||
@param {Object} [opts] | ||
@param {Array} [opts.asyc=false] Perform this task asynchronously. | ||
@param {Boolean} [opts.asyc=false] Perform this task asynchronously. | ||
If you flag a task with this option, you must call the global | ||
@@ -39,0 +35,0 @@ `complete` method inside the task's action, for execution to proceed |
@@ -25,2 +25,6 @@ /* | ||
/** | ||
@name jake | ||
@namespace jake | ||
*/ | ||
utils = new (function () { | ||
@@ -63,11 +67,62 @@ var _mix = function (targ, src, merge, includeProto) { | ||
this.exec = function (arr, callback, opts) { | ||
var options = opts || {} | ||
, list = arr.slice() | ||
, printStdout = options.stdout | ||
, printStderr = options.stderr | ||
, breakOnError = typeof options.breakOnError != 'undefined' ? | ||
options.breakOnError : true | ||
/** | ||
@name jake.exec | ||
@static | ||
@function | ||
@description Executes shell-commands asynchronously with an optional | ||
final callback. | ||
` | ||
@param {String[]} cmds The list of shell-commands to execute | ||
@param {Function} [callback] Callback to run after executing the | ||
commands | ||
@param {Object} [opts] | ||
@param {Boolean} [opts.stdout=false] Print stdout from each command | ||
@param {Boolean} [opts.stderr=false] Print stderr from each command | ||
@param {Boolean} [opts.breakOnError=true] Stop further execution on | ||
the first error. | ||
@example | ||
var cmds = [ | ||
'echo "showing directories"' | ||
, 'ls -al | grep ^d' | ||
, 'echo "moving up a directory"' | ||
, 'cd ../' | ||
] | ||
, callback = function () { | ||
console.log('Finished running commands.'); | ||
} | ||
jake.exec(cmds, callback, {stdout: true}); | ||
*/ | ||
this.exec = function () { | ||
var args | ||
, arg | ||
, list | ||
, callback | ||
, opts = {} | ||
, printStdout = false | ||
, printStderr = false | ||
, breakOnError = true | ||
, run; | ||
args = Array.prototype.slice.call(arguments); | ||
// The list of shell-commands to run (make a copy) | ||
list = args.shift().slice(); | ||
// Get optional callback or opts | ||
while((arg = args.shift())) { | ||
if (typeof arg == 'function') { | ||
callback = arg; | ||
} | ||
else if (typeof arg == 'object') { | ||
opts = arg; | ||
} | ||
} | ||
// Override default options | ||
printStdout = !!opts.stdout; | ||
printStderr = !!opts.stderr; | ||
breakOnError = typeof opts.breakOnError != 'undefined' ? | ||
opts.breakOnError : true; | ||
run = function () { | ||
@@ -99,3 +154,3 @@ var sh | ||
} | ||
// POSIX platform get streaming output for shell-commands | ||
// POSIX platform gets streaming output for shell-commands | ||
// Ganking part of Node's child_process.exec to get cmdline args parsed | ||
@@ -138,3 +193,3 @@ else { | ||
else { | ||
if (callback) { | ||
if (typeof callback == 'function') { | ||
callback(); | ||
@@ -141,0 +196,0 @@ } |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "0.2.22", | ||
"version": "0.2.23", | ||
"author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)", | ||
@@ -13,0 +13,0 @@ "bin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103778
2394