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:

make hello

With this Makefile in the root of the project:

1hello:
2  echo "Hello, world!"
2. Update workspace.json

For each project for which you want to enable make, add a target in workspace.json:

1// ...
2"my-app": {
3    "targets": {
4        "make": {
5            "executor": "@nrwl/workspace:run-commands",
6                "options": {
7                "commands": [
8                    {
9                        "command": "make hello"
10                    }
11                ]
12            }
13        }
14        // ...
15    }
16}

For more information, see the run-commands api doc.

3. Trigger the executor from the terminal

To run the executor for a single project:

nx run my-app:make

To run the executor for all affected projects:

nx affected --target=make

For more information, see the nx affected.