project.json:

1{ 2 // ... 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
1nx run frontend:ls-project-root 2

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

Mixins

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

oneOf [required: commands, required: command]

commands

Array<oneOf [object , string]>

Commands to run in child process.

command

string

Command to run in child process.

parallel

boolean
Default: true

Run commands in parallel.

args

oneOf [Array<string>, 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

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.

env

Environment variables that will be made available to the commands. This property has priority over the .env files.

forwardAllArgs

boolean
Default: true

Whether arguments should be forwarded when interpolation is not present.

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.

__unparsed__

InternalHidden
Array<string>

No description available.