Skip to content

Commit

Permalink
yarn add should be used to install packages instead of `yarn instal…
Browse files Browse the repository at this point in the history
…l` (#9562)

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
  • Loading branch information
3 people authored Jan 2, 2024
1 parent 55e49b3 commit 67e06f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-cars-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/upgrade": patch
---

Updates the command used for installing packages with pnpm and yarn
8 changes: 5 additions & 3 deletions packages/upgrade/src/actions/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ async function runInstallCommand(
const cwd = fileURLToPath(ctx.cwd);
if (ctx.packageManager === 'yarn') await ensureYarnLock({ cwd });

const installCmd = ctx.packageManager === 'yarn' || ctx.packageManager === 'pnpm' ? 'add' : 'install';

await spinner({
start: `Installing dependencies with ${ctx.packageManager}...`,
end: `Installed dependencies!`,
Expand All @@ -132,7 +134,7 @@ async function runInstallCommand(
await shell(
ctx.packageManager,
[
'install',
installCmd,
...dependencies.map(
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, '')}`
),
Expand All @@ -144,7 +146,7 @@ async function runInstallCommand(
await shell(
ctx.packageManager,
[
'install',
installCmd,
'--save-dev',
...devDependencies.map(
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, '')}`
Expand All @@ -161,7 +163,7 @@ async function runInstallCommand(
error(
'error',
`Dependencies failed to install, please run the following command manually:\n${color.bold(
`${ctx.packageManager} install ${packages}`
`${ctx.packageManager} ${installCmd} ${packages}`
)}`
);
return ctx.exit(1);
Expand Down

0 comments on commit 67e06f9

Please sign in to comment.