Permalink
Browse files

execute and reenable methods.

  • Loading branch information...
1 parent bf63f29 commit 2c2bdf067eb35a96a4e061bb1854c6529d948d1f @mde mde committed Dec 31, 2011
Showing with 37 additions and 6 deletions.
  1. +12 −4 lib/task.js
  2. +23 −0 lib/visitors/reenabler.js
  3. +2 −2 lib/{task_visitor.js → visitors/runner.js}
View
@@ -1,7 +1,8 @@
var fs = require('fs')
, EventEmitter = require('events').EventEmitter
, TaskMixin
- , TaskVisitor = require('./task_visitor').TaskVisitor;
+ , Runner = require('./visitors/runner').Runner
+ , Reenabler = require('./visitors/runner').Reenabler;
/**
* @constructor
@@ -42,24 +43,31 @@ TaskMixin = new (function () {
// Run prereqs, run task
this.invoke = function () {
- this.args = Array.prototype.slice.call(arguments);
jake._invocationChain.push(this);
- TaskVisitor.visit(this);
+ this.args = Array.prototype.slice.call(arguments);
+ Runner.visit(this);
};
// Reenable, run task (no prereqs)
this.execute = function () {
+ jake._invocationChain.push(this);
+ this.reenable();
+ this.run();
};
this.reenable = function (deep) {
+ this.done = false;
+ if (deep) {
+ Reenabler.visit(this);
+ }
};
this.handlePrereqComplete = function (prereq) {
var self = this;
this._currentPrereqIndex++;
if (this._currentPrereqIndex < this.prereqs.length) {
setTimeout(function () {
- TaskVisitor.visitNextPrereq(self);
+ Runner.visitNextPrereq(self);
}, 0);
}
else {
View
@@ -0,0 +1,23 @@
+
+var Reenabler = new (function () {
+ var reenablePrereqs = function (task) {
+ var prereqs = task.prereqs
+ , prereq;
+ if (prereqs && prereqs.length) {
+ for (var i = 0, ii = prereqs.length; i < ii; i++) {
+ prereq = jake.Task[prereqs[i]];
+ if (prereq) {
+ prereq.done = false;
+ reenablePrereqs(prereq);
+ }
+ }
+ }
+ };
+
+ this.visit = function (task) {
+ reenablePrereqs(task);
+ };
+
+})();
+
+exports.Reenabler = Reenabler;
@@ -1,5 +1,5 @@
-var TaskVisitor = new (function () {
+var Runner = new (function () {
// Parse any positional args attached to the task-name
var parsePrereqName = function (name) {
@@ -61,4 +61,4 @@ var TaskVisitor = new (function () {
})();
-exports.TaskVisitor = TaskVisitor;
+exports.Runner = Runner;

0 comments on commit 2c2bdf0

Please sign in to comment.