feat: allow to specify the max amount of workers used by pnpm (#10056)

This commit is contained in:
Zoltan Kochan
2025-10-09 15:07:08 +02:00
committed by GitHub
parent 3d9a3c8c0f
commit 06d2160476
2 changed files with 9 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/worker": minor
"pnpm": minor
---
Allow to specify the max amount of pnpm workers via the PNPM_MAX_WORKERS environment variable.

View File

@@ -53,6 +53,9 @@ function createTarballWorkerPool (): WorkerPool {
}
function calcMaxWorkers () {
if (process.env.PNPM_MAX_WORKERS) {
return parseInt(process.env.PNPM_MAX_WORKERS)
}
if (process.env.PNPM_WORKERS) {
const idleCPUs = Math.abs(parseInt(process.env.PNPM_WORKERS))
return Math.max(2, availableParallelism() - idleCPUs) - 1