Skip to content

Commit

Permalink
fix(core): include target and configuration being run in env variables (
Browse files Browse the repository at this point in the history
#15668)

(cherry picked from commit 63eced7)
  • Loading branch information
FrozenPandaz committed Mar 15, 2023
1 parent 699a355 commit 27b0a29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/shared/reference/environment-variables.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Environment Variables

The following environment variables are ones that you can set to change the behavior of Nx in different environments.

| Property | Type | Description |
| -------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| NX_BASE | string | The default base branch to use when calculating the affected projects. Can be overridden on the command line with `--base`. |
Expand All @@ -16,3 +18,13 @@
| NX_VERBOSE_LOGGING | boolean | If set to `true`, will print debug information useful for troubleshooting |
| NX_DRY_RUN | boolean | If set to `true`, will perform a dry run of the generator. No files will be created and no packages will be installed. |
| NX_INTERACTIVE | boolean | If set to `true`, will allow Nx to prompt you in the terminal to answer some further questions when running generators. |

Nx will set the following environment variables so they can be accessible within the process even outside of executors and generators

| Property | Type | Description |
| ---------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------- |
| NX_TASK_TARGET_PROJECT | string | Set to the project name of the task being run. Use this to tell which project is being run. |
| NX_TASK_TARGET_TARGET | string | Set to the target name of the task being run. Use this to tell which target of the project is being run. |
| NX_TASK_TARGET_CONFIGURATION | string | Set to the configuration name of the task being run. Use this to tell which configuration of the target is being run. |
| NX_DRY_RUN | boolean | Set to `true` during dry runs of generators. Use this to avoid side effects during generators. |
| NX_INTERACTIVE | boolean | Set to `false` when running generators with `--interactive=false`. Use this to prevent prompting during generators |
2 changes: 2 additions & 0 deletions packages/nx/src/tasks-runner/forked-process-task-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ export class ForkedProcessTaskRunner {
) {
const env: NodeJS.ProcessEnv = {
NX_TASK_TARGET_PROJECT: task.target.project,
NX_TASK_TARGET_TARGET: task.target.target,
NX_TASK_TARGET_CONFIGURATION: task.target.configuration,
NX_TASK_HASH: task.hash,
// used when Nx is invoked via Lerna
LERNA_PACKAGE_NAME: task.target.project,
Expand Down

0 comments on commit 27b0a29

Please sign in to comment.