Skip to content

Commit

Permalink
fix: fix package installation with yarn 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kabir-Ivan committed Jul 24, 2024
1 parent 499c908 commit d3b9dbb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/constants/packageManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@ export const DEFAULT_PM = "npm";

export type PackageManager = "npm" | "yarn" | "pnpm";

export const PMS: Record<PackageManager, { lock: string; init: string; install: string }> = {
export const PMS: Record<PackageManager, { lock: string; init: string; install: string, withRegistry: (command: string, registry: string) => 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}`,
},
};

Expand Down
3 changes: 1 addition & 2 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>((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,
Expand Down

0 comments on commit d3b9dbb

Please sign in to comment.