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.

project.json:

{ // ... "targets": { //... "ls-project-root": { "executor": "nx:run-commands", "options": { "command": "ls apps/frontend/src" } } } }
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:

"create-script": { "executor": "nx:run-commands", "options": { "commands": [ "mkdir -p apps/frontend/scripts", "touch apps/frontend/scripts/my-script.sh", "chmod +x apps/frontend/scripts/my-script.sh" ], "parallel": false } }

Options

Mixins

This type has all of the properties below, but must also match this type:

oneOf [required: commands, required: command]

__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.