Skip to content

Commit

Permalink
Some fixes to Task-inheritance.
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Feb 6, 2012
1 parent 30ce6a7 commit b41d35a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/task/directory_task.js
Expand Up @@ -3,7 +3,11 @@ var DirectoryTask

DirectoryTask = function (name, prereqs, action, opts) {
this.modTime = null;
this.constructor.prototype.initialize.apply(this, arguments);
// Do constructor-work only on actual instances, not when used
// for inheritance
if (arguments.length) {
this.constructor.prototype.init.apply(this, arguments);
}
};
DirectoryTask.prototype = new FileTask();
DirectoryTask.prototype.constructor = DirectoryTask;
Expand Down
6 changes: 5 additions & 1 deletion lib/task/file_task.js
Expand Up @@ -92,7 +92,11 @@ FileBase = new (function () {

FileTask = function (name, prereqs, action, opts) {
this.modTime = null;
this.constructor.prototype.initialize.apply(this, arguments);
// Do constructor-work only on actual instances, not when used
// for inheritance
if (arguments.length) {
this.constructor.prototype.init.apply(this, arguments);
}
};
FileTask.prototype = new Task();
FileTask.prototype.constructor = FileTask;
Expand Down
8 changes: 6 additions & 2 deletions lib/task/task.js
Expand Up @@ -10,7 +10,11 @@ var fs = require('fs')
* A Jake task
*/
Task = function () {
this.constructor.prototype.initialize.apply(this, arguments);
// Do constructor-work only on actual instances, not when used
// for inheritance
if (arguments.length) {
this.constructor.prototype.init.apply(this, arguments);
}
};

Task.prototype = new EventEmitter();
Expand All @@ -32,7 +36,7 @@ TaskBase = new (function () {
};
};

this.initialize = function (name, prereqs, action, options) {
this.init = function (name, prereqs, action, options) {
var opts = options || {};

this._currentPrereqIndex = 0;
Expand Down

0 comments on commit b41d35a

Please sign in to comment.