Jake

12.9.7 · active · verified Sun Apr 19

Jake is a JavaScript build tool and task runner for Node.js, designed to operate similarly to traditional build systems like GNU Make or Ruby's Rake. It is currently at version 12.9.7, with active maintenance and a consistent release cadence to support newer Node.js versions. Key differentiators include defining build tasks in plain JavaScript files (Jakefiles), supporting complex task prerequisites, namespacing for organization, and handling asynchronous task execution. Jake offers synchronous file utilities for common build operations and can be installed globally as a CLI, locally as a dev dependency, or embedded programmatically within other applications. It has a long history in the Node.js ecosystem, indicating a mature and well-tested codebase.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define tasks and namespaces in a `Jakefile.js`, including prerequisites and an asynchronous task, and how to execute them from the command line.

/* Jakefile.js */
const { desc, task, namespace } = require('jake');

desc('This is the default task.');
task('default', function () {
  console.log('Running the default task.');
});

namespace('build', function () {
  desc('Cleans the build directory.');
  task('clean', function () {
    console.log('Cleaning build artifacts...');
    // Example: jake.rmRf('dist'); (requires 'jake' object)
  });

  desc('Compiles source files.');
  task('compile', ['build:clean'], function () {
    console.log('Compiling source...');
    // Simulate async operation
    setTimeout(() => {
      console.log('Compilation complete.');
      this.complete(); // Important for async tasks
    }, 1000);
  }, { async: true });

  desc('Lints JavaScript files.');
  task('lint', function () {
    console.log('Running linter...');
  });

  desc('Performs a full build, including linting.');
  task('all', ['build:lint', 'build:compile'], function () {
    console.log('Full build finished!');
  });
});

desc('Runs all tests.');
task('test', ['build:all'], function () {
  console.log('Running tests...');
});

// To run:
// npm install -g jake
// jake default
// jake build:all
// jake test

view raw JSON →