nr
  • 👋Welcome
  • Getting Started
    • Install
    • Environment
    • Configuration File
  • Configuration Reference
    • command
    • task
    • script
  • CLI Reference
    • CLI Reference
Powered by GitBook
On this page
  • task
  • name: string
  • taskFn: TaskFn
  1. Configuration Reference

task

PreviouscommandNextscript

Last updated 2 years ago

A task in nr is a user-provided function. They can be used to perform any work that is not suited to invoking an external CLI. However, they run in the same thread as nr, so be mindful of blocking code when using them in parallel.

To create a task, use the function at the task property of the context object passed to your configuration function:

nr.config.js
export default ({ task }) => {
    
};

task

This function accepts the following parameters:

name: string

Human friendly name for the task. This will be used for error-reporting and can be used to reference the task in scripts.

taskFn:

Function to call when this task is executed.

Return Type
Description

Value that may be provided to script to run the task.

When task is called, it creates a TaskThunk, a function that can be invoked to run the task. This function is added to a registry using the tasks name, and then it is returned. There are two ways to reference a task in a script:

  1. Use the TaskThunk directly in a script definition.

  2. Use a string in the form task:name to instruct nr to look-up the task in the registry.

TaskFn
TaskThunk
Page cover image