Skip to main content

Executing Task

When executing tasks, Nadle ensures the following rules are enforced:

  • Each task is executed at most once per run, even if listed multiple times via the CLI or required by multiple tasks.
  • Dependencies are always executed before their dependents, unless explicitly excluded using options like --exclude.
  • The order of dependencies in dependsOn is not guaranteed; Nadle determines the optimal execution order based on the dependency graph and may adjust it at any time.

Running a Single Task

To run a task, use the Nadle CLI from your terminal:

nadle build

This command runs the build task in the current workspace. If the task is not found and the current workspace is not the root, Nadle will fall back to the root workspace.

Running Multiple Tasks

You can run multiple tasks in a single Nadle command by listing them:

nadle check build test

By default, Nadle will run these tasks sequentially, one after another, in the order specified. This ensures that each task completes before the next begins.

To run multiple tasks in parallel, add the --parallel flag:

nadle eslint prettier spell-check --parallel

With --parallel, Nadle will run the eslint, prettier, and spell-check tasks at the same time, as long as there are no dependencies between them. If any of these tasks declare dependencies, Nadle will still ensure the dependencies are completed before running the dependent task, even in parallel mode.

Running Task with Dependencies

If a task declares dependencies using the dependsOn option, Nadle will automatically execute all dependencies before running the dependent task. Each dependency is only run once per execution, even if multiple tasks depend on it.

Example:

tasks.register("build").config({
dependsOn: ["lint", "test"]
});

Running nadle build will execute lint and test first, then build.

Running Tasks in Specific Workspace

You can run a task in a specific workspace by prefixing the workspace ID or label, regardless of where the command is executed:

nadle packages:app:build
nadle api:lint

Running Root Workspace Tasks

When you run a root-scoped task (e.g., nadle root:build or just nadle build from the root), Nadle will:

  • Run the root workspace's version of the task first.
  • Then run all tasks with the same name in other workspaces, except those already scheduled due to dependencies.

This allows you to orchestrate and trigger the same-named tasks across your monorepo.

note

Running a task in a sub-workspace does not automatically trigger the root workspace's version of the task. Only the explicitly referenced workspace's task will run.

See Task and Workspace for more details on task and workspace concepts.

Excluding Tasks

You can skip specific tasks during execution using the --exclude option. This is useful when you want to run a group of tasks but intentionally leave out certain ones, even if they are listed as dependencies or in the CLI.

Example:

nadle build test --exclude lint

In this example, Nadle will run the build and test tasks, but will skip the lint task—even if lint is a dependency of build or test. Any excluded task will not be executed for the current run.

You can exclude multiple tasks by repeating the flag or providing a comma-separated list:

nadle build --exclude lint,spell-check

Task and Workspace Name Autocorrect

Nadle automatically suggests and corrects task and workspace names if you mistype or use a partial name.

For example:

nadle backe:biuld
# Nadle will resolve to 'backend:build'

For more details and examples, see Auto-correction.