From 68a30542b4758b0393d45e4242bcd77d4dc6cbad Mon Sep 17 00:00:00 2001 From: Eric Willhoit Date: Thu, 21 Sep 2023 15:38:13 -0500 Subject: [PATCH] feat: yarn network mutex --- src/yarn.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/yarn.ts b/src/yarn.ts index 2dad9d1b..dae0eb57 100644 --- a/src/yarn.ts +++ b/src/yarn.ts @@ -46,11 +46,17 @@ export default class Yarn { async exec(args: string[] = [], opts: {cwd: string; verbose: boolean}): Promise { const cwd = opts.cwd if (args[0] !== 'run') { + // https://classic.yarnpkg.com/lang/en/docs/cli/#toc-concurrency-and-mutex + // Default port is: 31997 + const port = this.config.scopedEnvVar('NETWORK_MUTEX_PORT') + const optionalPort = port ? `:${port}` : '' + const mutex = this.config.scopedEnvVar('USE_NETWORK_MUTEX') ? `network${optionalPort}` : `file:${path.join(cwd, 'yarn.lock')}` + console.log('mutex', mutex); const cacheDir = path.join(this.config.cacheDir, 'yarn') args = [ ...args, '--non-interactive', - `--mutex=file:${path.join(cwd, 'yarn.lock')}`, + `--mutex=${mutex}`, `--preferred-cache-folder=${cacheDir}`, '--check-files', ]