JavaScript build tool, similar to Make or Rake
npx @tessl/cli install tessl/npm-jake@10.9.0Jake is a JavaScript build tool for Node.js that provides functionality similar to Make or Rake. It allows developers to define build tasks in JavaScript using a familiar task-based approach, with support for file dependencies, asynchronous operations, and command-line execution.
npm install jake (global: npm install -g jake)// Import the entire Jake API
const jake = require('jake');
// Or import specific functions (globals are also available)
const { task, desc, file, directory, namespace } = require('jake');When using Jake as a build tool, the API functions are automatically available as globals in Jakefiles.
// Define a simple task
desc('Default task');
task('default', function() {
console.log('Hello from Jake!');
});
// Define a task with prerequisites
desc('Build project');
task('build', ['clean', 'compile'], function() {
console.log('Building project...');
});
// Create a file task that checks modification times
file('dist/app.js', ['src/app.js'], function() {
// This only runs if src/app.js is newer than dist/app.js
jake.exec(['uglifyjs src/app.js -o dist/app.js'], function() {
complete();
});
}, { async: true });
// Create a directory task
directory('dist');
// Run Jake from command line: `jake build`Jake is built around several key components:
Define and execute build tasks with prerequisites, asynchronous operations, and file dependency checking. The foundation of Jake's build automation.
function task(name, prereqs, action, opts);
function file(name, prereqs, action, opts);
function directory(name);
function desc(description);
function complete(task, value);
function fail(err, code);
function series(...tasks);
function setTaskTimeout(timeout);
function setSeriesAutoPrefix(prefix);Specialized task types for common build operations including package creation, publishing, and test execution with built-in conventions.
function packageTask(name, version, prereqs, definition);
function publishTask(name, prereqs, opts, definition);
function npmPublishTask(name, prereqs, opts, definition);
function testTask(name, prereqs, definition);Organize tasks hierarchically using namespaces and create dynamic tasks using pattern-based rules for scalable build systems.
function namespace(name, closure);
function rule(pattern, source, prereqs, action, opts);Built-in utilities for shell command execution and file operations, providing cross-platform build automation capabilities.
function exec(cmds, opts, callback);
function createExec(cmds, opts, callback);
function uuid(length, radix);
function cpR(fromPath, toPath, opts);
function mkdirP(dir, mode);
function rmRf(path, options);
function isAbsolute(path);
function absolutize(path);Direct access to Jake's task class hierarchy for programmatic task creation and advanced build system development.
class Task extends EventEmitter;
class FileTask extends Task;
class DirectoryTask extends FileTask;
class PackageTask;
class PublishTask;
class TestTask;The main Jake object provides access to all functionality and system state:
interface Jake extends EventEmitter {
version: string;
errorCode: number;
logger: Logger;
exec: Function;
createExec: Function;
uuid: Function;
FileList: FileListConstructor;
Task: TaskConstructor;
FileTask: FileTaskConstructor;
DirectoryTask: DirectoryTaskConstructor;
PackageTask: PackageTaskConstructor;
PublishTask: PublishTaskConstructor;
TestTask: TestTaskConstructor;
Namespace: NamespaceConstructor;
Rule: RuleConstructor;
// File utilities
cpR: Function;
mkdirP: Function;
rmRf: Function;
isAbsolute: Function;
absolutize: Function;
// Task system
parseAllTasks(): void;
showAllTaskDescriptions(filter?: string): void;
run(...args: any[]): void;
setTaskTimeout(timeout: number): void;
setSeriesAutoPrefix(prefix: string): void;
// Namespaces
rootNamespace: RootNamespace;
defaultNamespace: RootNamespace;
currentNamespace: Namespace;
// Task management
currentTaskDescription: string | null;
createTask(type: string, ...args: any[]): Task;
loader: Loader;
program: Program;
// Internal properties
_invocationChain: Task[];
_taskTimeout: number;
_seriesAutoPrefix: string;
}