Page cover

script

Scripts are the entry-point to nr; they are what the user will reference from the command line to run a group of commands, tasks, or other scripts.

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

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

script

This function accepts the following parameters:

name: string

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

options: ScriptOptions

Configuration object for the script. Its properties are detailed below.

group?: string

...

description?: string

...

run: Array<Instruction>

...

timing?: boolean

Default: false

...

Parameter
Type
Description

name

string

Name of the command.

args

Executable and arguments.

options?

Optional configuration.

Return Type
Description

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

This function accepts a name, an array indicating the executable and its arguments, CommandArguments, and an optional options object, CommandOptions. It will register the command using the provided name and return a value. To reference a command in a script, use either the return value from command directly or a string in the format cmd:name. Commands are executed using execa.

CommandArguments may take one of four forms:

  • [executable] of type [string]

  • [executable, positionals] of type [string, Array<string>]

  • [executable, flags] of type [string, Record<string, any>]

  • [executable, positionals, flags] of type [string, Array<string>, Record<string, any>]

Last updated