Comparing version 0.1.14 to 0.1.16
@@ -20,12 +20,11 @@ #!/usr/bin/env node | ||
require.paths.push(__dirname + '/../lib'); | ||
var args = process.argv.slice(2) | ||
, libPath = __dirname + '/../lib' | ||
, fs = require('fs') | ||
, sys = require('sys') | ||
, jake = require('jake') | ||
, api = require('api') | ||
, Program = require('program.js').Program | ||
, jake = require(libPath + '/jake.js') | ||
, api = require(libPath + '/api.js') | ||
, Program = require(libPath + '/program.js').Program | ||
, program = new Program() | ||
, Loader = require('loader.js').Loader | ||
, Loader = require(libPath + '/loader.js').Loader | ||
, loader = new Loader() | ||
@@ -55,2 +54,6 @@ , pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json').toString()) | ||
// Get convenient refs to FileList, PackageTask | ||
jake.FileList = require(libPath + '/file_list').FileList | ||
jake.PackageTask = require(libPath + '/package_task').PackageTask | ||
// Enhance env with any env vars passed in | ||
@@ -57,0 +60,0 @@ for (var p in envVars) { process.env[p] = envVars[p]; } |
@@ -283,3 +283,2 @@ /* | ||
jake.FileList = FileList; | ||
exports.FileList = FileList; |
@@ -77,2 +77,7 @@ /* | ||
var Invocation = function (taskName, args) { | ||
this.taskName = taskName; | ||
this.args = args; | ||
}; | ||
/** | ||
@@ -139,4 +144,7 @@ * @namespace | ||
*/ | ||
, _parsePrereqs = function (name, isRoot, includePrereqs) { | ||
, _parsePrereqs = function (name, opts) { | ||
var task = _this.getTask(name) | ||
, includePrereqs = opts.includePrereqs || false | ||
, isRoot = opts.isRoot || false | ||
, args = opts.args | ||
, prereqs = task ? task.prereqs : []; | ||
@@ -152,6 +160,6 @@ | ||
for (var i = 0, ii = prereqs.length; i < ii; i++) { | ||
_parsePrereqs(prereqs[i], false, includePrereqs); | ||
_parsePrereqs(prereqs[i], {isRoot: false, includePrereqs: includePrereqs}); | ||
} | ||
} | ||
_workingTaskList.push(name); | ||
_workingTaskList.push(new Invocation(name, args)); | ||
} | ||
@@ -174,17 +182,6 @@ }; | ||
this.populateAndProcessTaskList = function (name, includePrereqs, callback) { | ||
var opts = { | ||
root: true | ||
, includePrereqs: includePrereqs | ||
}; | ||
// Parse all the prerequisites up front. This allows use of a simple | ||
// queue to run all the tasks in order, and treat sync/async essentially | ||
// the same. | ||
_parsePrereqs(name, opts, callback); | ||
this.createTree = function (name, opts) { | ||
_parsePrereqs(name, opts); | ||
}; | ||
this.createTree = function (name, isRoot, includePrereqs) { | ||
_parsePrereqs(name, isRoot, includePrereqs); | ||
}; | ||
/** | ||
@@ -200,10 +197,12 @@ * Initial function called to run the specified task. Parses all the | ||
this.runTask = function (name, args, includePrereqs) { | ||
this.createTree(name, true, includePrereqs); | ||
this.createTree(name, {isRoot: true, includePrereqs: includePrereqs, args: args}); | ||
_taskList.splice.apply(_taskList, [_taskIndex, 0].concat(_workingTaskList)); | ||
_workingTaskList = []; | ||
this.runNextTask(args); | ||
this.runNextTask(); | ||
}; | ||
this.reenableTask = function (name, includePrereqs) { | ||
_parsePrereqs(name, true, includePrereqs); | ||
var invocation | ||
, task; | ||
_parsePrereqs(name, {isRoot: true, includePrereqs: includePrereqs}); | ||
if (!_workingTaskList.length) { | ||
@@ -214,4 +213,4 @@ fail('No tasks to reenable.'); | ||
for (var i = 0, ii = _workingTaskList.length; i < ii; i++) { | ||
name = _workingTaskList[i]; | ||
task = this.getTask(name); | ||
invocation = _workingTaskList[i]; | ||
task = this.getTask(invocation.taskName); | ||
task.done = false; | ||
@@ -249,5 +248,7 @@ } | ||
*/ | ||
this.runNextTask = function (args) { | ||
var name = _taskList[_taskIndex] | ||
this.runNextTask = function () { | ||
var invocation = _taskList[_taskIndex] | ||
, name | ||
, task | ||
, args | ||
, prereqs | ||
@@ -260,4 +261,8 @@ , prereqName | ||
// If there are still tasks to run, do it | ||
if (name) { | ||
if (invocation) { | ||
name = invocation.taskName; | ||
args = invocation.args; | ||
_taskIndex++; | ||
task = this.getTask(name); | ||
@@ -296,4 +301,4 @@ | ||
// the one for this file (or this file doesn't exist yet) | ||
if (!(prereqTask instanceof FileTask || prereqTask instanceof DirectoryTask) | ||
|| (!modTime || _modTimes[prereqName] > modTime)) { | ||
if ((prereqTask && !(prereqTask instanceof FileTask || prereqTask instanceof DirectoryTask)) | ||
|| (!modTime || _modTimes[prereqName] >= modTime)) { | ||
if (typeof task.action == 'function') { | ||
@@ -300,0 +305,0 @@ task.action.apply(task, args || []); |
@@ -21,3 +21,2 @@ /* | ||
, fs = require('fs') | ||
, list = require('file_list') | ||
, exec = require('child_process').exec | ||
@@ -76,2 +75,3 @@ , currDir = process.cwd(); | ||
exec('rm -fr ' + self.packageDir, function (err, stdout, stderr) { | ||
if (err) { throw err; } | ||
complete(); | ||
@@ -98,2 +98,3 @@ }); | ||
exec(cmd, function (err, stdout, stderr) { | ||
if (err) { throw err; } | ||
// Return back up to the project directory | ||
@@ -142,2 +143,3 @@ process.chdir(currDir); | ||
exec('cp ' + file.to + ' ' + file.from, function (err, stdout, stderr) { | ||
if (err) { throw err; } | ||
_copyFile(); | ||
@@ -144,0 +146,0 @@ }); |
@@ -116,3 +116,3 @@ /* | ||
// Parse out any env-vars and task-name | ||
while (!!(cmd = cmds.shift())) { | ||
while (!!(cmd = cmds.pop())) { | ||
cmdItems = cmd.split('='); | ||
@@ -119,0 +119,0 @@ if (cmdItems.length > 1) { |
{ "name": "jake" | ||
, "version": "0.1.14" | ||
, "version": "0.1.16" | ||
, "author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)" | ||
@@ -4,0 +4,0 @@ , "bin": { "jake": "./bin/cli.js" } |
@@ -21,2 +21,16 @@ ### Jake -- JavaScript build tool for Node.js | ||
### Installing on Windows | ||
*Assumed: current directory is the same directory where node.exe is present.* | ||
Get Jake: | ||
git clone git://github.com/mde/jake.git node_modules/jake | ||
Copy jake.bat to the same directory as node.exe | ||
copy node_modules/jake/jake.bat jake.bat | ||
Add the directory of node.exe to the environment PATH variable. | ||
### Basic usage | ||
@@ -57,5 +71,5 @@ | ||
j## Tasks | ||
## Tasks | ||
Use `task` or `file` to define tasks. Call it with two arguments (and one optional argument): | ||
Use `task` to define tasks. Call it with two arguments (and one optional argument): | ||
@@ -94,11 +108,20 @@ task(name/prerequisites, action, [async]); | ||
Create a file-task by calling `file`. | ||
File-tasks create a file from one or more other files. With a file-task, Jake checks both that the file exists, and also that it is not older than the files specified by any prerequisite tasks. File-tasks are particularly useful for compiling something from a tree of source files. | ||
Create a file task by calling `file`. | ||
desc('This builds a minified JS file for production.'); | ||
file({'foo-minified.js': ['foo-bar.js', 'foo-baz.js']}, function () { | ||
file({'foo-minified.js': ['bar', 'foo-bar.js', 'foo-baz.js']}, function () { | ||
// Code to concat and minify goes here | ||
}); | ||
### Directory-tasks | ||
Create a directory-task by calling `directory`. | ||
Directory-tasks create a directory for use with for file-tasks. Jake checks for the existence of the directory, and only creates it if needed. | ||
desc('This creates the bar directory for use with the foo-minified.js file-task.'); | ||
directory('bar'); | ||
### Namespaces | ||
@@ -155,3 +178,3 @@ | ||
Any paramters passed after the Jake task that contain an equals sign (=) will be added to process.env. | ||
Any parameters passed after the Jake task that contain an equals sign (=) will be added to process.env. | ||
@@ -217,3 +240,3 @@ With the following Jakefile: | ||
If you want to run the task and its prerequisites more than once, you can use `invoke` with the `reenable` method. | ||
If you want to run the task and its prerequisites more than once, you can use `invoke` with the `re-enable` method. | ||
@@ -227,7 +250,7 @@ desc('Calls the foo:bar task and its prerequisites.'); | ||
// Only re-runs foo:bar, but not its prerequisites | ||
jake.Task['foo:bar'].reenable(); | ||
jake.Task['foo:bar'].re-enable(); | ||
jake.Task['foo:bar'].invoke(); | ||
}); | ||
The `reenable` method takes a single Boolean arg, a 'deep' flag, which reenables the task's prerequisites if set to true. | ||
The `re-enable` method takes a single Boolean arg, a 'deep' flag, which reenables the task's prerequisites if set to true. | ||
@@ -241,3 +264,3 @@ desc('Calls the foo:bar task and its prerequisites.'); | ||
// Only re-runs foo:bar, but not its prerequisites | ||
jake.Task['foo:bar'].reenable(true); | ||
jake.Task['foo:bar'].re-enable(true); | ||
jake.Task['foo:bar'].invoke(); | ||
@@ -277,3 +300,3 @@ }); | ||
Passing `jake` the -T or --tasks flag will display the full list of tasks avaliable in a Jakefile, along with their descriptions: | ||
Passing `jake` the -T or --tasks flag will display the full list of tasks available in a Jakefile, along with their descriptions: | ||
@@ -301,4 +324,3 @@ $ jake -T | ||
var PackageTask = require('package_task').PackageTask | ||
, t = new PackageTask('fonebone', 'v0.1.2112', function () { | ||
var t = new jake.PackageTask('fonebone', 'v0.1.2112', function () { | ||
var fileList = [ | ||
@@ -335,4 +357,3 @@ 'Jakefile' | ||
var FileList = require('file_list').FileList | ||
, list = new FileList(); | ||
var list = new jake.FileList(); | ||
list.include('foo/*.txt'); | ||
@@ -339,0 +360,0 @@ list.include(['bar/*.txt', 'README.md']); |
@@ -78,3 +78,3 @@ var parseargs = require('../lib/parseargs') | ||
// -f expects a value, -t does not (foo=bar is env-var, task-name follows) | ||
p.parse(z('-f zoobie -t foo=bar howdy')); | ||
p.parse(z('-f zoobie -t howdy foo=bar')); | ||
assert.equal('zoobie', p.opts.jakefile); | ||
@@ -109,3 +109,3 @@ assert.equal(true, p.opts.trace); | ||
// Opts, env vars, task-name with positional args | ||
p.parse(z('-f ./tests/Jakefile -t foo=bar default[asdf,qwer]')); | ||
p.parse(z('-f ./tests/Jakefile -t default[asdf,qwer] foo=bar')); | ||
assert.equal('./tests/Jakefile', p.opts.jakefile); | ||
@@ -112,0 +112,0 @@ assert.equal(true, p.opts.trace); |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
63643
1390
404
14
12