Permalink
Browse files

task/namspace/etc. should return the created object.

  • Loading branch information...
1 parent c014de4 commit c70e317e06163842156577cf4bfbdc62fd0378c0 mde committed Jun 28, 2012
Showing with 19 additions and 11 deletions.
  1. +13 −6 lib/api.js
  2. +6 −5 lib/test_task.js
View
@@ -51,10 +51,12 @@ var api = new (function () {
*/
this.task = function (name, prereqs, action, opts) {
var args = Array.prototype.slice.call(arguments)
- , type;
+ , type
+ , createdTask;
args.unshift('task');
- jake.createTask.apply(global, args);
+ createdTask = jake.createTask.apply(global, args);
jake.currentTaskDescription = null;
+ return createdTask;
};
/**
@@ -73,10 +75,12 @@ var api = new (function () {
directory('pkg');
*/
this.directory = function (name) {
- var args = Array.prototype.slice.call(arguments);
+ var args = Array.prototype.slice.call(arguments)
+ , createdTask;
args.unshift('directory');
- jake.createTask.apply(global, args);
+ createdTask = jake.createTask.apply(global, args);
jake.currentTaskDescription = null;
+ return createdTask;
};
/**
@@ -97,10 +101,12 @@ var api = new (function () {
*/
this.file = function (name, prereqs, action, opts) {
- var args = Array.prototype.slice.call(arguments);
+ var args = Array.prototype.slice.call(arguments)
+ , createdTask;
args.unshift('file');
- jake.createTask.apply(global, args);
+ createdTask = jake.createTask.apply(global, args);
jake.currentTaskDescription = null;
+ return createdTask;
};
/**
@@ -147,6 +153,7 @@ var api = new (function () {
scope();
jake.currentNamespace = curr;
jake.currentTaskDescription = null;
+ return ns;
};
/**
View
@@ -128,7 +128,9 @@ var TestTask = function (name, definition) {
// 'this' will be the task when action is run
return a.call(this, cb);
};
- };
+ }
+ // Dummy top-level task for everything to be prereqs for
+ , topLevel;
// Pull in each test-file, and iterate over any exported
// test-functions. Register each test-function as a prereq task
@@ -172,13 +174,12 @@ var TestTask = function (name, definition) {
// Create the dummy top-level task. When calling a task internally
// with `invoke` that is async (or has async prereqs), have to listen
// for the 'complete' event to know when it's done
- task('__top__', prereqs);
- var t = jake.Task[self.testName + 'Exec:__top__'];
- t.addListener('complete', function () {
+ topLevel = task('__top__', prereqs);
+ topLevel.addListener('complete', function () {
jake.logger.log('All tests ran successfully');
complete();
});
- t.invoke(); // Do the thing!
+ topLevel.invoke(); // Do the thing!
});
}, {async: true});
});

0 comments on commit c70e317

Please sign in to comment.