From 024966ef73f13553e446090b91725b26bc5deac4 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Mon, 9 Oct 2023 15:47:21 -0400 Subject: [PATCH] feat(core): add NX_PARALLEL env var (#19488) --- docs/shared/reference/environment-variables.md | 1 + packages/nx/src/utils/command-line-utils.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/shared/reference/environment-variables.md b/docs/shared/reference/environment-variables.md index 4d0888129d582..a9632bcc939e7 100644 --- a/docs/shared/reference/environment-variables.md +++ b/docs/shared/reference/environment-variables.md @@ -14,6 +14,7 @@ The following environment variables are ones that you can set to change the beha | NX_PROFILE | string | Prepend `NX_PROFILE=profile.json` before running targets with Nx to generate a file that be [loaded in Chrome dev tools](/recipes/troubleshooting/performance-profiling) to visualize the performance of Nx across multiple processes. | | NX_PROJECT_GRAPH_CACHE_DIRECTORY | string | The project graph cache is stored in `node_modules/.cache/nx` by default. Set this variable to use a different directory. | | NX_PROJECT_GRAPH_MAX_WORKERS | number | The number of workers to use when calculating the project graph. | +| NX_PARALLEL | number | The number of tasks Nx should run in parallel. Overrides any configured value inside nx.json | | NX_RUNNER | string | The name of task runner from the config to use. Can be overridden on the command line with `--runner`. Not read if NX_TASKS_RUNNER is set. | | NX_SKIP_NX_CACHE | boolean | Rerun the tasks even when the results are available in the cache | | NX_TASKS_RUNNER | string | The name of task runner from the config to use. Can be overridden on the command line with `--runner`. Preferred over NX_RUNNER. | diff --git a/packages/nx/src/utils/command-line-utils.ts b/packages/nx/src/utils/command-line-utils.ts index 267b098491380..1348a16d82f45 100644 --- a/packages/nx/src/utils/command-line-utils.ts +++ b/packages/nx/src/utils/command-line-utils.ts @@ -180,10 +180,14 @@ export function splitArgsIntoNxArgsAndOverrides( } else if ( args['parallel'] === 'true' || args['parallel'] === true || - args['parallel'] === '' + args['parallel'] === '' || + process.env.NX_PARALLEL // dont require passing --parallel if NX_PARALLEL is set ) { nxArgs['parallel'] = Number( - nxArgs['maxParallel'] || nxArgs['max-parallel'] || 3 + nxArgs['maxParallel'] || + nxArgs['max-parallel'] || + process.env.NX_PARALLEL || + 3 ); } else if (args['parallel'] !== undefined) { nxArgs['parallel'] = Number(args['parallel']);