From d3b9dbbd6a4114261951bfae6996df0319ddb106 Mon Sep 17 00:00:00 2001 From: Ivan Kabir Date: Wed, 24 Jul 2024 14:05:34 +0300 Subject: [PATCH] fix: fix package installation with yarn 4 --- src/constants/packageManagement.ts | 5 ++++- src/package.ts | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/constants/packageManagement.ts b/src/constants/packageManagement.ts index 786ce04..88a9fa0 100644 --- a/src/constants/packageManagement.ts +++ b/src/constants/packageManagement.ts @@ -11,21 +11,24 @@ export const DEFAULT_PM = "npm"; export type PackageManager = "npm" | "yarn" | "pnpm"; -export const PMS: Record = { +export const PMS: Record string }> = { npm: { lock: "package-lock.json", init: "init -y", install: "install --save-dev", + withRegistry: (command, registry) => `${command} --registry ${registry}`, }, yarn: { lock: "yarn.lock", init: "init -y", install: "add -D", + withRegistry: (command, registry) => `export YARN_REGISTRY=${registry} && export YARN_NPM_REGISTRY_SERVER=${registry} && ${command}`, }, pnpm: { lock: "pnpm-lock.yml", init: "init", install: "add --save-dev", + withRegistry: (command, registry) => `${command} --registry ${registry}`, }, }; diff --git a/src/package.ts b/src/package.ts index 1cdcfc8..377a57e 100644 --- a/src/package.ts +++ b/src/package.ts @@ -91,10 +91,9 @@ export const installPackages = async ( const spinner = ora("Installing packages (this may take a while)").start(); const pluginsPackages = pluginsToInstall.map(packageNameFromPlugin).join(" "); - return new Promise((resolve, reject) => { exec( - `${packageManager} ${PMS[packageManager].install} testplane ${pluginsPackages} --registry "${registry}"`, + PMS[packageManager].withRegistry(`${packageManager} ${PMS[packageManager].install} testplane ${pluginsPackages}`, registry), { cwd: dirPath, env: process.env,