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