Browse files

Switched to more robust check for arrayness for dependencies.

  • Loading branch information...
1 parent 8b8b3f2 commit b4ac5965e1f787e66ed3f8e1b4b7d544b04c577c mde committed Aug 26, 2010
Showing with 17 additions and 4 deletions.
  1. +17 −4 lib/jake.js
View
21 lib/jake.js
@@ -113,6 +113,15 @@ if (jakefile[0] != '/') {
}
var jake = new function () {
+
+ var _isArray = function (obj) {
+ return obj &&
+ typeof obj === 'object' &&
+ typeof obj.length === 'number' &&
+ typeof obj.splice === 'function' &&
+ !(obj.propertyIsEnumerable('length'));
+ };
+
this.currentNamespace = 'default';
this.currentTaskDescription = null;
this.namespaceTasks = {
@@ -141,10 +150,13 @@ var jake = new function () {
var task = this.getTask(name);
var deps = task.deps;
- if (deps && deps instanceof Array) {
+
+ // If we have some dependent tasks, run 'em
+ if (deps && _isArray(deps)) {
deps = deps.slice();
+
var _complete = global.complete;
- var runDependencies = global.complete = function (){
+ var runDependencies = global.complete = function () {
if (deps.length == 0) {
global.complete = _complete;
_doRunTask();
@@ -153,7 +165,6 @@ var jake = new function () {
}
return;
}
-
var async = false;
do {
if (!deps.length) {
@@ -165,8 +176,10 @@ var jake = new function () {
async = jake.getTask(depName).async;
} while (!async && global.complete === runDependencies);
};
+
runDependencies();
- } else {
+ }
+ else {
_doRunTask();
}

0 comments on commit b4ac596

Please sign in to comment.