nx:run-commands

Run any custom commands with Nx.

Options can be configured in project.json when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.

workspace.json:

1//...
2"frontend": {
3    "targets": {
4        //...
5        "ls-project-root": {
6            "executor": "nx:run-commands",
7            "options": {
8                "command": "ls apps/frontend/src"
9            }
10        }
11    }
12}
13
nx run frontend:ls-project-root

Examples

The commands option accepts as many commands as you want. By default, they all run in parallel. You can run them sequentially by setting parallel: false:

1"create-script": {
2    "executor": "nx:run-commands",
3    "options": {
4        "commands": [
5          "mkdir -p apps/frontend/scripts",
6          "touch apps/frontend/scripts/my-script.sh",
7          "chmod +x apps/frontend/scripts/my-script.sh"
8        ],
9        "parallel": false
10    }
11}
12

Options

__unparsed__

Hidden
Array<string>

No description available.

args

string

Extra arguments. You can pass them as follows: nx run project:target --args='--wait=100'. You can then use {args.wait} syntax to interpolate them in the workspace config file. See example above

commands

Array<oneOf [object , string]>

Commands to run in child process.

command

string

Command to run in child process.

color

boolean
Default: false

Use colors when showing output of command.

cwd

string

Current working directory of the commands. If it's not specified the commands will run in the workspace root, if a relative path is specified the commands will run in that path relative to the workspace root and if it's an absolute path the commands will run in that path.

envFile

string

You may specify a custom .env file path.

outputPath

oneOf [string, Array<string>]

Allows you to specify where the build artifacts are stored. This allows Nx Cloud to pick them up correctly, in the case that the build artifacts are placed somewhere other than the top level dist folder.

parallel

boolean
Default: true

Run commands in parallel.

readyWhen

string

String to appear in stdout or stderr that indicates that the task is done. When running multiple commands, this option can only be used when parallel is set to true. If not specified, the task is done when all the child processes complete.

Additional Properties

anything

Extra properties of any type may be provided to this object.