Skip to content

Commit

Permalink
task/namspace/etc. should return the created object.
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Jun 28, 2012
1 parent c014de4 commit c70e317
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
19 changes: 13 additions & 6 deletions lib/api.js
Expand Up @@ -51,10 +51,12 @@ var api = new (function () {
*/ */
this.task = function (name, prereqs, action, opts) { this.task = function (name, prereqs, action, opts) {
var args = Array.prototype.slice.call(arguments) var args = Array.prototype.slice.call(arguments)
, type; , type
, createdTask;
args.unshift('task'); args.unshift('task');
jake.createTask.apply(global, args); createdTask = jake.createTask.apply(global, args);
jake.currentTaskDescription = null; jake.currentTaskDescription = null;
return createdTask;
}; };


/** /**
Expand All @@ -73,10 +75,12 @@ var api = new (function () {
directory('pkg'); directory('pkg');
*/ */
this.directory = function (name) { this.directory = function (name) {
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments)
, createdTask;
args.unshift('directory'); args.unshift('directory');
jake.createTask.apply(global, args); createdTask = jake.createTask.apply(global, args);
jake.currentTaskDescription = null; jake.currentTaskDescription = null;
return createdTask;
}; };


/** /**
Expand All @@ -97,10 +101,12 @@ var api = new (function () {
*/ */
this.file = function (name, prereqs, action, opts) { 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'); args.unshift('file');
jake.createTask.apply(global, args); createdTask = jake.createTask.apply(global, args);
jake.currentTaskDescription = null; jake.currentTaskDescription = null;
return createdTask;
}; };


/** /**
Expand Down Expand Up @@ -147,6 +153,7 @@ var api = new (function () {
scope(); scope();
jake.currentNamespace = curr; jake.currentNamespace = curr;
jake.currentTaskDescription = null; jake.currentTaskDescription = null;
return ns;
}; };


/** /**
Expand Down
11 changes: 6 additions & 5 deletions lib/test_task.js
Expand Up @@ -128,7 +128,9 @@ var TestTask = function (name, definition) {
// 'this' will be the task when action is run // 'this' will be the task when action is run
return a.call(this, cb); 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 // Pull in each test-file, and iterate over any exported
// test-functions. Register each test-function as a prereq task // test-functions. Register each test-function as a prereq task
Expand Down Expand Up @@ -172,13 +174,12 @@ var TestTask = function (name, definition) {
// Create the dummy top-level task. When calling a task internally // Create the dummy top-level task. When calling a task internally
// with `invoke` that is async (or has async prereqs), have to listen // with `invoke` that is async (or has async prereqs), have to listen
// for the 'complete' event to know when it's done // for the 'complete' event to know when it's done
task('__top__', prereqs); topLevel = task('__top__', prereqs);
var t = jake.Task[self.testName + 'Exec:__top__']; topLevel.addListener('complete', function () {
t.addListener('complete', function () {
jake.logger.log('All tests ran successfully'); jake.logger.log('All tests ran successfully');
complete(); complete();
}); });
t.invoke(); // Do the thing! topLevel.invoke(); // Do the thing!
}); });
}, {async: true}); }, {async: true});
}); });
Expand Down

0 comments on commit c70e317

Please sign in to comment.