From a49a84e753a9d91ee062c9e4f8e162b09b8a89c2 Mon Sep 17 00:00:00 2001 From: Tim Fisher Date: Sat, 23 Sep 2023 03:37:03 +0100 Subject: [PATCH] feat(core): add NX_IGNORE_CYCLES environment variable (#18708) --- docs/shared/reference/environment-variables.md | 1 + packages/nx/src/tasks-runner/run-command.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/shared/reference/environment-variables.md b/docs/shared/reference/environment-variables.md index 18b0cda6a09d0..4d0888129d582 100644 --- a/docs/shared/reference/environment-variables.md +++ b/docs/shared/reference/environment-variables.md @@ -23,6 +23,7 @@ The following environment variables are ones that you can set to change the beha | 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_GENERATE_QUIET | boolean | If set to `true`, will prevent Nx logging file operations during generate | | NX_PREFER_TS_NODE | boolean | If set to `true`, Nx will use ts-node for local execution of plugins even if `@swc-node/register` is installed. | +| NX_IGNORE_CYCLES | boolean | If set to `true`, Nx will ignore errors created by a task graph circular dependency. Can be overriden on the command line with `--nxIgnoreCycles` | Nx will set the following environment variables so they can be accessible within the process even outside of executors and generators diff --git a/packages/nx/src/tasks-runner/run-command.ts b/packages/nx/src/tasks-runner/run-command.ts index f03fed086dd56..b651dc6a75490 100644 --- a/packages/nx/src/tasks-runner/run-command.ts +++ b/packages/nx/src/tasks-runner/run-command.ts @@ -117,7 +117,7 @@ function createTaskGraphAndValidateCycles( const cycle = findCycle(taskGraph); if (cycle) { - if (nxArgs.nxIgnoreCycles) { + if (process.env.NX_IGNORE_CYCLES === 'true' || nxArgs.nxIgnoreCycles) { output.warn({ title: `The task graph has a circular dependency`, bodyLines: [`${cycle.join(' --> ')}`],