From c2cec80d0920cc9036d94dee337f4aa9fff34615 Mon Sep 17 00:00:00 2001 From: Nicky Kalu Date: Fri, 23 Aug 2024 08:05:12 +0300 Subject: [PATCH] feat: Enable override to NPM_CONCURRENCY defaults through env variable (#972) --- README.md | 4 ++++ change/beachball-3a1535e5-d3c6-4f91-a673-17f6e527edb3.json | 7 +++++++ src/env.ts | 2 ++ src/packageManager/listPackageVersions.ts | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 change/beachball-3a1535e5-d3c6-4f91-a673-17f6e527edb3.json diff --git a/README.md b/README.md index d8a384b5a..b3d96441d 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,10 @@ show help message skips the prompts for publish +## Overriding Concurrency + +In large monorepos, the Beachball sync process can be time-consuming due to the high number of packages. To optimize performance, you can override the default concurrency (typically set to 2 or 5) by setting the NPM_CONCURRENCY environment variable to a value that best suits your needs + ## Examples ``` diff --git a/change/beachball-3a1535e5-d3c6-4f91-a673-17f6e527edb3.json b/change/beachball-3a1535e5-d3c6-4f91-a673-17f6e527edb3.json new file mode 100644 index 000000000..54381ce2c --- /dev/null +++ b/change/beachball-3a1535e5-d3c6-4f91-a673-17f6e527edb3.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "override NPM_CONCURRENCY defaults through env variable", + "packageName": "beachball", + "email": "nickykalu@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/src/env.ts b/src/env.ts index 428b2534a..8606f7c12 100644 --- a/src/env.ts +++ b/src/env.ts @@ -17,4 +17,6 @@ export const env = Object.freeze({ // These are borrowed from workspace-tools workspaceToolsGitDebug: !!process.env.GIT_DEBUG, workspaceToolsGitMaxBuffer: (process.env.GIT_MAX_BUFFER && parseInt(process.env.GIT_MAX_BUFFER, 10)) || undefined, + // Override default NPM_CONCURRENCY + npmConcurrency: (process.env.NPM_CONCURRENCY && parseInt(process.env.NPM_CONCURRENCY)) || undefined }); diff --git a/src/packageManager/listPackageVersions.ts b/src/packageManager/listPackageVersions.ts index 2ebcd7323..5390180b7 100644 --- a/src/packageManager/listPackageVersions.ts +++ b/src/packageManager/listPackageVersions.ts @@ -18,7 +18,7 @@ export type NpmShowResult = PackageJson & { let packageVersionsCache: { [pkgName: string]: NpmShowResult | false } = {}; -const NPM_CONCURRENCY = env.isJest ? 2 : 5; +const NPM_CONCURRENCY = env.npmConcurrency ?? (env.isJest ? 2 : 5); export function _clearPackageVersionsCache(): void { packageVersionsCache = {};