From 1e19abaecb3fd7b6ff0932b46ee129e04d1496b3 Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Tue, 20 Jul 2021 02:51:56 -0700 Subject: [PATCH] fix: using regex to determine yarn version to account for newer releases of yarn (i.e. yarn 3). fixes: #6069 (#6071) --- packages/app-builder-lib/src/util/yarn.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/app-builder-lib/src/util/yarn.ts b/packages/app-builder-lib/src/util/yarn.ts index 75148dcebe..8eaf68a077 100644 --- a/packages/app-builder-lib/src/util/yarn.ts +++ b/packages/app-builder-lib/src/util/yarn.ts @@ -74,6 +74,15 @@ export function getGypEnv(frameworkInfo: DesktopFrameworkInfo, platform: NodeJS. } } +function checkYarnBerry () { + const npmUserAgent = process.env["npm_config_user_agent"] || '' + const regex = /yarn\/(\d+)\./gm; + + const yarnVersionMatch = regex.exec(npmUserAgent); + const yarnMajorVersion = Number(yarnVersionMatch?.[1] ?? 0) + return yarnMajorVersion >= 2; +} + function installDependencies(appDir: string, options: RebuildOptions): Promise { const platform = options.platform || process.platform const arch = options.arch || process.arch @@ -82,9 +91,8 @@ function installDependencies(appDir: string, options: RebuildOptions): Promise