Configuration File
Last updated
Last updated
nr
is configured using a JavaScript configuration file named nr.config.js
that should be placed in the root directory of your project.
A configuration file is responsible for creating commands, tasks, and scripts:
Commands describe the invocation of a single executable and any arguments provided to it, as well as any configuration related to how the command should be invoked and how its output should be handled.
Tasks are JavaScript functions that may execute arbitrary code. They may be synchronous or asynchronous.
Scripts are the entry-point to nr
. They compose commands, tasks, and other scripts that may run sequentially, in parallel, or a combination of both.
A configuration file must export a function that will be passed a ConfigurationFactoryContext
object that contains the following properties:
Key | Type | Description |
---|---|---|
These functions are documented in more detail later in this guide.
The examples in this guide are written in modern ESM syntax. If your project is configured to support this syntax, either by declaring "type": "module"
in package.json
or via Babel, you can author your nr
configuration file the same way.
Note: If your project uses Babel to provide support for modern language features, nr
will automatically use your project's local Babel configuration. You do not need to use a .babel.js
extension.
If your project is not configured to support ESM syntax, you will need to author your configuration file using CommonJS syntax:
Here, we will define a simple script that runs a single command that outputs "Hello world!". Use this as a sanity check to ensure nr
can find and parse your configuration file. The concepts used here will be covered in more detail later in the guide.
Verify that you can run this script using one of the following commands, depending on how you have configured your environment:
Once you have created your configuration file, proceed to the next section to learn how to create your first script.
function
Creates a new command.
function
Creates a new task.
function
Creates a new script.
isCI
boolean
true
in CI environments. See is-ci
.