Skip to content

Commit

Permalink
fix: add -w arg when updating pnpm root workspace (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
huang-julien authored Aug 23, 2024
1 parent 38ea768 commit e84529c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/commands/upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { execSync } from 'node:child_process'
import { existsSync } from 'node:fs'
import { consola } from 'consola'
import { colors } from 'consola/utils'
import { relative, resolve } from 'pathe'
Expand Down Expand Up @@ -27,6 +28,11 @@ async function getNuxtVersion(path: string): Promise<string | null> {
}
}

function hasPnpmWorkspaceFile(cwd: string): boolean {
const pnpmWorkspaceFilePath = resolve(cwd, 'pnpm-workspace.yaml')
return existsSync(pnpmWorkspaceFilePath)
}

export default defineCommand({
meta: {
name: 'upgrade',
Expand Down Expand Up @@ -88,7 +94,7 @@ export default defineCommand({
execSync(
`${packageManager} ${
packageManager === 'yarn' ? 'add' : 'install'
} -D nuxt`,
} -D nuxt ${packageManager === 'pnpm' && hasPnpmWorkspaceFile(cwd) ? '-w' : ''}`,
{ stdio: 'inherit', cwd },
)

Expand Down

0 comments on commit e84529c

Please sign in to comment.