or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

build-tasks.mdcore-tasks.mdindex.mdtask-classes.mdtask-organization.mdutilities.md
tile.json

tessl/npm-jake

JavaScript build tool, similar to Make or Rake

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/jake@10.9.x

To install, run

npx @tessl/cli install tessl/npm-jake@10.9.0

index.mddocs/

Jake

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

Package Information

  • Package Name: jake
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install jake (global: npm install -g jake)

Core Imports

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

Basic Usage

// 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`

Architecture

Jake is built around several key components:

  • Task System: Core task definition and execution with prerequisite handling
  • File Tasks: File-based tasks with automatic modification time checking
  • Rule System: Pattern-based task generation for flexible build systems
  • Namespace System: Hierarchical task organization to prevent naming conflicts
  • Execution Engine: Asynchronous task execution with dependency resolution
  • Utility Functions: Built-in file operations and shell command execution

Capabilities

Core Task System

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);

Core Task System

Build Task Types

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);

Build Task Types

Task Organization

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);

Task Organization

Utility Functions

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);

Utility Functions

Task Classes

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;

Task Classes

Global Jake Object

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;
}