Permalink
Browse files

Started work on evented exec.

  • Loading branch information...
1 parent ea0f2ac commit 83afef7f97fe45628726848bf7c25e2afb43c966 mde committed May 20, 2012
Showing with 25 additions and 4 deletions.
  1. +25 −4 lib/utils/index.js
View
29 lib/utils/index.js
@@ -19,8 +19,10 @@
var exec = require('child_process').exec
, spawn = require('child_process').spawn
+ , EventEmitter = require('events').EventEmitter
, fileUtils = require('./file')
- , utils;
+ , utils
+ , Exec;
/**
@name jake
@@ -62,7 +64,6 @@ utils = new (function () {
return str;
};
-
/**
@name jake.exec
@static
@@ -159,9 +160,10 @@ utils = new (function () {
});
// Exit, handle err or run next
sh.on('exit', function (code) {
- var msg = errData || 'Process exited with error.';
- msg = _trim(msg);
+ var msg;
if (breakOnError && code != 0) {
+ msg = errData || 'Process exited with error.';
+ msg = _trim(msg);
fail(msg, code);
}
else {
@@ -237,6 +239,25 @@ utils = new (function () {
})();
+Exec = function (cmds, opts) {
+ var options = opts || {};
+ this.cmds = cmds;
+ this.config = {
+ stdout: false
+ , stderr: false
+ , breakOnError: true
+ };
+ utils.mixin(this.config, options);
+};
+Exec.prototype = new EventEmitter();
+Exec.prototype.constructor = Exec;
+utils.mixin(Exec.prototype, new (function () {
+
+
+})());
+
+utils.Exec = Exec;
+
// Hang all the file utils off this too
utils.mixin(utils, fileUtils);

0 comments on commit 83afef7

Please sign in to comment.