Jake -- JavaScript build tool for Node.js

Installing

By default Jake is installed in "/usr/local." To install it into a different
directory (e.g., one that doesn't require super-user privilege), pass the PREFIX
variable to the make install command. For example, to install it into a
"jake" directory in your home directory, you could use this:

make && make install PREFIX=~/jake

If do you install Jake somewhere special, you'll need to add the "bin" directory
in the install target to your PATH to get access to the jake executable.

Note that Jake is a system-level tool, and wants to be installed globally.

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

jake [options ...] [env variables ...] target

Description

Jake is a simple JavaScript build program with capabilities similar to the
regular make or rake command.
Jake has the following features:
* Jakefiles are in standard JavaScript syntax
* Tasks with prerequisites
* Namespaces for tasks
* Async task execution

Jakefile syntax

A Jakefile is just executable JavaScript. You can include whatever JavaScript
you want in it.

Tasks

Use task to define tasks. Call it with two arguments (and one optional
argument):

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 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.

File-tasks

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.

desc('Calls the foo:bar task without its prerequisites.');
task('executeFooBar', function () {
// Calls foo:bar without its prereqs
jake.Task['foo:baz'].execute();
// Can keep running this over and over
jake.Task['foo:baz'].execute();
jake.Task['foo:baz'].execute();
});

If you want to run the task and its prerequisites more than once, you can use
invoke with the reenable method.

desc('Calls the foo:bar task and its prerequisites.');
task('invokeFooBar', function () {
// Calls foo:bar and its prereqs
jake.Task['foo:bar'].invoke();
// Does nothing
jake.Task['foo:bar'].invoke();
// Only re-runs foo:bar, but not its prerequisites
jake.Task['foo:bar'].reenable();
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.

desc('Calls the foo:bar task and its prerequisites.');
task('invokeFooBar', function () {
// Calls foo:bar and its prereqs
jake.Task['foo:bar'].invoke();
// Does nothing
jake.Task['foo:bar'].invoke();
// Only re-runs foo:bar, but not its prerequisites
jake.Task['foo:bar'].reenable(true);
jake.Task['foo:bar'].invoke();
});

This will automatically create a 'package' task that will assemble the specified
files in 'pkg/fonebone-v0.1.2112,' and compress them according to the specified
options. After running jake package, you'll have the following in pkg/:

PackageTask also creates a 'clobberPackage' task that removes the pkg/
directory, and a 'repackage' task that forces the package to be rebuilt.

PackageTask requires NodeJS's minimatchmodule
(https://github.com/isaacs/minimatch). It is used in FileList, which is used to
specify the list of files to include in your PackageTask (the packageFiles
property). (See FileList, below.)

FileList

Jake's FileList takes a list of glob-patterns and file-names, and lazy-creates a
list of files to include. Instead of immediately searching the filesystem to
find the files, a FileList holds the pattern until it is actually used.

When any of the normal JavaScript Array methods (or the toArray method) are
called on the FileList, the pending patterns are resolved into an actual list of
file-names. FileList uses NodeJS's minimatchmodule
(https://github.com/isaacs/minimatch).

To build the list of files, use FileList's include and exclude methods:

The include method can be called either with an array of items, or multiple
single parameters. Items can be either glob-patterns, or individual file-names.

The exclude method will prevent files from being included in the list. These
files must resolve to actual files on the filesystem. It can be called either
with an array of items, or mutliple single parameters. Items can be
glob-patterns, individual file-names, string-representations of
regular-expressions, or regular-expression literals.

NpmPublishTask

The NpmPublishTask builds on top of PackageTask to allow you to do a version
bump of your project, package it, and publish it to NPM. Define the task with
your project's name, and the list of files you want packaged and published to
NPM.