task
Last updated
Last updated
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:
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.
Function to call when this task is executed.
Return Type | Description |
---|---|
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:
Use the TaskThunk
directly in a script definition.
Use a string in the form task:name
to instruct nr
to look-up the task in the registry.
Value that may be provided to script
to run the task.