nx/docs/shared/recipes/running-tasks/running-custom-commands.md
Jack Hsu 66eaf2fc74
docs(misc): remove /nx-api pages (#31453)
This PR removes the `/nx-api` pages from `nx-dev`. They are already
redirected from `/nx-api` to either `/technologies` or
`/reference/core-api` URLs.

e.g. `/nx-api/nx` goes to `/reference/core-api/nx` and `/nx-api/react`
goes to `/technologies/react/api`

**Changes**:
- Remove old `nx-api.json` from being generated in
`scripts/documentation/generators/generate-manifests.ts` -- this was
used to generate the sitemap
- Remove `pages/nx-api` from Next.js app since we don't need them
- Remove workaround from link checker
`scripts/documentation/internal-link-checker.ts` -- the angular
rspack/rsbuild and other workarounds are gone now that they are proper
docs in `map.json`
- Update Powerpack/Remote Cache reference docs to exclude API documents
(since they are duplicated in the Intro page) --
`nx-dev/models-document/src/lib/mappings.ts`
- All content in `docs` have been updated with new URL structure

**Note:** Redirects are already handled, and Claude Code was used to
verify the updated `docs/` URLs (see report below). The twelve 404s
links were updated by hand.

## Verification Report

https://gist.github.com/jaysoo/c7863fe7e091cb77929d1976165c357a
2025-06-04 16:57:01 -04:00

66 lines
1.4 KiB
Markdown

---
title: Running Custom Commands
description: Learn how to run custom terminal commands with Nx to make them cacheable, distributable, and compatible with Nx's affected commands.
---
# Running Custom Commands
You can easily run any command with the Nx toolchain. The main benefit is to make the [operation cacheable](/concepts/how-caching-works), [distributable](/ci/features/distribute-task-execution) as well as being able to use it [with Nx's affected commands](/ci/features/affected).
## 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:
```make
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": {
"command": "make hello"
}
// ...
}
```
For more information (e.g. how to forward arguments), see the [run-commands api doc](/reference/core-api/nx/executors/run-commands).
## 3. Run the command
To run the command, use the usual Nx syntax:
```shell
nx run my-app:make
```
or
```shell
nx make my-app
```
You can also run the `make` command for all projects it has been defined on:
```shell
nx run-many -t make
```
Or just on a subset of projects that are [affected by a given change](/ci/features/affected):
```shell
nx affected -t make
```