nx/docs/shared/running-custom-commands.md
2022-10-13 21:25:40 +00:00

60 lines
1.1 KiB
Markdown

# Running Custom Commands
This recipe will show how to run any terminal command within the nx build-chain.
## Steps
##### 1. Define the terminal command to be run
The command we want to run for each project is:
```shell
make hello
```
With this `Makefile` in the root of the project:
```shell
hello:
echo "Hello, world!"
```
##### 2. Update `project.json`
For each project for which you want to enable `make`, add a target in its `project.json`:
```jsonc {% fileName="project.json" %}
// ...
"targets": {
"make": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "make hello"
}
]
}
}
// ...
}
```
For more information, see the [run-commands api doc](/packages/nx/executors/run-commands).
##### 3. Trigger the executor from the terminal
To run the executor for a single project:
```shell
nx run my-app:make
```
To run the executor for all affected projects:
```shell
nx affected --target=make
```
For more information, see the [nx affected](/nx/affected).