Comparing version 0.1.21 to 0.1.22
@@ -32,7 +32,9 @@ /* | ||
Task.prototype = new (function () { | ||
this.initialize = function (name, prereqs, action, async, type) { | ||
this.initialize = function (name, prereqs, action, options, type) { | ||
var opts = options || {}; | ||
this.name = name; | ||
this.prereqs = prereqs; | ||
this.action = action; | ||
this.async = (async === true); | ||
//this.async = (async === true); | ||
this.async = false; | ||
this.type = type; | ||
@@ -42,2 +44,12 @@ this.done = false; | ||
this.desription = null; | ||
// Support legacy async-flag -- if not explicitly passed or falsy, will | ||
// be set to empty-object | ||
if (typeof opts == 'boolean' && opts === true) { | ||
this.async = true; | ||
} | ||
else { | ||
if (opts.async) { | ||
this.async = true; | ||
} | ||
} | ||
}; | ||
@@ -60,3 +72,3 @@ | ||
var FileTask = function (name, prereqs, action, async, type) { | ||
var FileTask = function (name, prereqs, action, opts, type) { | ||
this.constructor.prototype.initialize.apply(this, arguments); | ||
@@ -67,3 +79,3 @@ }; | ||
var DirectoryTask = function (name, prereqs, action, async, type) { | ||
var DirectoryTask = function (name, prereqs, action, opts, type) { | ||
this.constructor.prototype.initialize.apply(this, arguments); | ||
@@ -445,3 +457,3 @@ }; | ||
, action | ||
, async | ||
, opts | ||
, prereqs = []; | ||
@@ -451,25 +463,25 @@ | ||
// name, [deps], [action] | ||
// Older name (string) + deps (array) format | ||
if (typeof args[0] == 'string') { | ||
name = args.shift(); | ||
if (_isArray(args[0])) { | ||
prereqs = args.shift(); | ||
} | ||
if (typeof args[0] == 'function') { | ||
action = args.shift(); | ||
async = args.shift(); | ||
} | ||
// name, [deps], [action] | ||
// Name (string) + deps (array) format | ||
if (typeof args[0] == 'string') { | ||
name = args.shift(); | ||
if (_isArray(args[0])) { | ||
prereqs = args.shift(); | ||
} | ||
// name:deps, [action] | ||
// Newer object-literal syntax, e.g.: {'name': ['depA', 'depB']} | ||
else { | ||
obj = args.shift() | ||
for (var p in obj) { | ||
prereqs = prereqs.concat(obj[p]); | ||
name = p; | ||
} | ||
if (typeof args[0] == 'function') { | ||
action = args.shift(); | ||
async = args.shift(); | ||
opts = args.shift() || {}; | ||
} | ||
} | ||
// name:deps, [action] | ||
// Legacy object-literal syntax, e.g.: {'name': ['depA', 'depB']} | ||
else { | ||
obj = args.shift() | ||
for (var p in obj) { | ||
prereqs = prereqs.concat(obj[p]); | ||
name = p; | ||
} | ||
action = args.shift(); | ||
opts = args.shift() || {}; | ||
} | ||
@@ -482,9 +494,9 @@ if (type == 'directory') { | ||
}; | ||
task = new DirectoryTask(name, prereqs, action, async, type); | ||
task = new DirectoryTask(name, prereqs, action, opts, type); | ||
} | ||
else if (type == 'file') { | ||
task = new FileTask(name, prereqs, action, async, type); | ||
task = new FileTask(name, prereqs, action, opts, type); | ||
} | ||
else { | ||
task = new Task(name, prereqs, action, async, type); | ||
task = new Task(name, prereqs, action, opts, type); | ||
} | ||
@@ -491,0 +503,0 @@ |
{ "name": "jake" | ||
, "version": "0.1.21" | ||
, "version": "0.1.22" | ||
, "author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)" | ||
@@ -4,0 +4,0 @@ , "bin": { "jake": "./bin/cli.js" } |
@@ -74,11 +74,10 @@ ### Jake -- JavaScript build tool for Node.js | ||
task(name, [prerequisites], action, [async]); | ||
task(name, [prerequisites], action, [opts]); | ||
The `name` argument is a String with the name of the task, and `prerequisites` is an optional Array arg of the list of prerequisite tasks to perform first. The `action` is a Function defininng the action to take for the task. (Note that Object-literal syntax for name/prerequisites in a single argument a la Rake is also supported, but JavaScript's lack of support for dynamic keys in Object literals makes it not very useful.) | ||
The `async` argument is optional, and when set to `true` (`async === true`) indicates the task executes asynchronously. Asynchronous tasks need to call `complete()` to signal they have completed. | ||
The `opts` argument is optional, and when it includes an `async` property set to `true`, indicates the task executes asynchronously. Asynchronous tasks need to call `complete()` to signal they have completed. (Passing a final `async` Boolean flag is deprecated, but still supported.) | ||
Tasks created with `task` are always executed when asked for (or are a prerequisite). Tasks created with `file` are only executed if no file with the given name exists or if any of its file-prerequisites are more recent than the file named by the task. Also, if any prerequisite is a regular task, the file task will always be executed. | ||
Use `desc` to add a string description of the task. | ||
@@ -103,3 +102,3 @@ | ||
setTimeout(complete, 1000); | ||
}, true); | ||
}, {async: true}); | ||
@@ -106,0 +105,0 @@ ### File-tasks |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68069
1490
414