Skip to content

Commit 4ce456d

Browse files
authored
Supports Yarn v2 and Yarn v3
This pull request enables user to use yarn berry (aka yarn v2 and yarn v3) as their package manager, and fixed ionic-team#4483
1 parent 866d8fc commit 4ce456d

File tree

1 file changed

+12
-1
lines changed
  • packages/@ionic/cli/src/lib/utils

1 file changed

+12
-1
lines changed

packages/@ionic/cli/src/lib/utils/npm.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,30 @@ export async function pkgManagerArgs(npmClient: NpmClient, options: PkgManagerOp
7676
}
7777
}
7878

79+
const installerExec: string = '';
7980
const installerArgs: string[] = [];
8081

8182
switch (npmClient) {
8283
case 'npm':
84+
installerExec = 'npm';
8385
vocab = { run: 'run', install: 'i', bareInstall: 'i', uninstall: 'uninstall', dedupe: 'dedupe', rebuild: 'rebuild', global: '-g', save: '--save', saveDev: '-D', saveExact: '-E', nonInteractive: '', lockFileOnly: '--package-lock-only' };
8486
break;
8587
case 'yarn':
88+
installerExec = 'yarn';
8689
vocab = { run: 'run', install: 'add', bareInstall: 'install', uninstall: 'remove', dedupe: '', rebuild: 'install', global: '', save: '', saveDev: '--dev', saveExact: '--exact', nonInteractive: '--non-interactive', lockFileOnly: '' };
8790
if (options.global) { // yarn installs packages globally under the 'global' prefix, instead of having a flag
8891
installerArgs.push('global');
8992
}
9093
break;
94+
case 'yarn-berry':
95+
installerExec = 'yarn';
96+
vocab = { run: 'run', install: 'add', bareInstall: 'install', uninstall: 'remove', dedupe: '', rebuild: 'install', global: '', save: '', saveDev: '--dev', saveExact: '--exact', nonInteractive: '', lockFileOnly: '' };
97+
if (options.global) { // yarn installs packages globally under the 'global' prefix, instead of having a flag
98+
installerArgs.push('global');
99+
}
100+
break;
91101
case 'pnpm':
102+
installerExec = 'pnpm';
92103
vocab = { run: 'run', install: 'add', bareInstall: 'install', uninstall: 'remove', dedupe: '', rebuild: 'rebuild', global: '--global', save: '', saveDev: '--save-dev', saveExact: '--save-exact', nonInteractive: '', lockFileOnly: '--lockfile-only' };
93104
break;
94105
default:
@@ -171,7 +182,7 @@ export async function pkgManagerArgs(npmClient: NpmClient, options: PkgManagerOp
171182
installerArgs.push('--json');
172183
}
173184

174-
return [npmClient, ...installerArgs];
185+
return [installerExec, ...installerArgs];
175186
}
176187

177188
/**

0 commit comments

Comments
 (0)