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

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

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

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

oneOf [string, Array<string>]

String or array of strings to appear in stdout or stderr that indicate 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.

tty

Hidden
boolean

Whether commands should be run with a tty terminal

Additional Properties

anything

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

__unparsed__

InternalHidden
Array<string>

No description available.