From 7d55f49e7d29d156a3d5b18c0d0af96eb35987bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Jona=C5=A1?= Date: Thu, 17 Aug 2023 16:28:29 +0200 Subject: [PATCH] fix(core): use existing version when calling "yarn set version" (#18669) --- packages/create-nx-workspace/src/utils/package-manager.ts | 8 +++----- packages/nx/src/utils/package-manager.ts | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/create-nx-workspace/src/utils/package-manager.ts b/packages/create-nx-workspace/src/utils/package-manager.ts index 30f248d2cb90f..9400fe7b25812 100644 --- a/packages/create-nx-workspace/src/utils/package-manager.ts +++ b/packages/create-nx-workspace/src/utils/package-manager.ts @@ -38,17 +38,15 @@ export function getPackageManagerCommand( exec: string; preInstall?: string; } { - const [pmMajor, pmMinor] = - getPackageManagerVersion(packageManager).split('.'); + const pmVersion = getPackageManagerVersion(packageManager); + const [pmMajor, pmMinor] = pmVersion.split('.'); switch (packageManager) { case 'yarn': const useBerry = +pmMajor >= 2; const installCommand = 'yarn install --silent'; return { - preInstall: useBerry - ? 'yarn set version stable' - : 'yarn set version classic', + preInstall: `yarn set version ${pmVersion}`, install: useBerry ? installCommand : `${installCommand} --ignore-scripts`, diff --git a/packages/nx/src/utils/package-manager.ts b/packages/nx/src/utils/package-manager.ts index 896f568efbb07..3a66103548642 100644 --- a/packages/nx/src/utils/package-manager.ts +++ b/packages/nx/src/utils/package-manager.ts @@ -65,9 +65,7 @@ export function getPackageManagerCommand( const useBerry = gte(yarnVersion, '2.0.0'); return { - preInstall: useBerry - ? 'yarn set version stable' - : 'yarn set version classic', + preInstall: `yarn set version ${yarnVersion}`, install: 'yarn', ciInstall: useBerry ? 'yarn install --immutable'