Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

how to: run custom terminal commands #4

Open
Hotell opened this issue Dec 17, 2019 · 0 comments
Open

how to: run custom terminal commands #4

Hotell opened this issue Dec 17, 2019 · 0 comments

Comments

@Hotell
Copy link
Contributor

Hotell commented Dec 17, 2019

Run a terminal command for each affected project

Compodoc is a great tool for automatically generating documentation for Angular projects. In order to use it, you need to run a simple command in the terminal.

This recipe will show how to run any terminal command within the nx build-chain using Compodoc as an example.

Steps

  1. Define the terminal command to be run
    The command we want to run for each project is:

compodoc -p [path/to/tsconfig.json]

  1. Update workspace.json

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

@nrwl/workspace:run-commands API

"compodoc": {
  "builder": "@nrwl/workspace:run-commands",
  "options": {
    "commands": [
      {
        "command": "npx compodoc -p apps/my-app/tsconfig.app.json"
      }
    ]
  }
},

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

Note: Replace apps/my-app/tsconfig.app.json with the appropriate tsconfig.json path for each project.

  1. Trigger the builder from the terminal
    To run the builder for a single project:
nx run my-app:compodoc

To run the builder for all affected projects:

nx affected --target=compodoc

For more information, see the nx affected api doc.


Pass custom args to custom terminal commands

how to achieve following (standard npm script functionality) ?

nx run my-app:compodoc --my --custom --args='foo'

While possible, at the moment it's quite cumbersome -> see nrwl/nx#2241 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant