From d31798ceabcc0ff9faadb4c2d620e958836ef149 Mon Sep 17 00:00:00 2001 From: Filip Kublin Date: Fri, 13 Dec 2024 15:08:51 +0100 Subject: [PATCH] test: add --lockfile-only param for pnpm --- test/utils/add-to-package-json.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/utils/add-to-package-json.ts b/test/utils/add-to-package-json.ts index 80ad600..ce38b6c 100644 --- a/test/utils/add-to-package-json.ts +++ b/test/utils/add-to-package-json.ts @@ -30,10 +30,20 @@ export const addToPackageJson = async ( ); const installCommand = await getInstallCommand(testDirectory); - try { - await execAsync(installCommand, { cwd: testDirectory }); - } catch (err) { - console.log("ERROR: ", err); + if (await exists(path.resolve(testDirectory, "pnpm-lock.yaml"))) { + try { + await execAsync(`${installCommand} --lockfile-only`, { + cwd: testDirectory, + }); + } catch (err) { + console.log("ERROR: ", err); + } + } else { + try { + await execAsync(installCommand, { cwd: testDirectory }); + } catch (err) { + console.log("ERROR: ", err); + } } await addPackage(testDirectory, depName, packageDetails, licenseFiles);