just ___
Home
Guide
GitHub
Home
Guide
GitHub
  • Tasks
    • Getting started
    • Composition of tasks
    • Logging
    • Command line arguments
    • Conditionals
    • Higher order task functions
  • Scripts
    • Introduction
    • TypeScript
    • Webpack
    • Lint
    • Jest

Composition of tasks

Once a project gets a bit more complex, a build step might consist of multiple sub tasks. This can be achieved with composition. This is the main reason just-task was made. It simplifies the composition of tasks.

Running tasks in a series

const { task, series } = require('just-task');

task('clean', function () {
  // clean stuff
});

task('babel', function () {
  // run babel over some files
});

task('build', series('clean', 'babel'));

When you trigger just build, the clean task will run and complete before babel task is run.

Running tasks in parallel

To take advantage of multi-core CPUs on our machines, we can run several tasks in parallel. Simply use the parallel() function.

const { task, parallel } = require('just-task');

task('babel', function () {
  // run babel babel over some files
});

task('lint', function () {
  // run eslint over some files
});

task('build', parallel('babel', 'lint'));

Nesting tasks in series and parallel

The most powerful feature of just-task is its ability to compose tasks by nesting tasks in series and parallel. Let's combine the previous examples.

const { task, parallel, series } = require('just-task');

task('babel', function () {
  // run babel babel over some files
});

task('lint', function () {
  // run eslint over some files
});

task('build', series('clean', parallel('babel', 'lint')));
Last Updated: 12/11/25, 5:07 PM
Prev
Getting started
Next
Logging