From 0c1860a05635a41ebf135d60798bddf3e75e6f81 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 27 Oct 2021 19:46:09 +0800 Subject: [PATCH] feat(nuxi): support pnpm for nuxi upgrade (#1516) --- packages/nuxi/src/commands/upgrade.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nuxi/src/commands/upgrade.ts b/packages/nuxi/src/commands/upgrade.ts index 5a2792931e..7c7047b5de 100644 --- a/packages/nuxi/src/commands/upgrade.ts +++ b/packages/nuxi/src/commands/upgrade.ts @@ -25,10 +25,12 @@ export default defineNuxtCommand({ const yarnLock = 'yarn.lock' const npmLock = 'package-lock.json' + const pnpmLock = 'pnpm-lock.yaml' const isYarn = existsSync(resolve(rootDir, yarnLock)) const isNpm = existsSync(resolve(rootDir, npmLock)) - const packageManager = isYarn ? 'yarn' : isNpm ? 'npm' : null + const isPnpm = existsSync(resolve(rootDir, pnpmLock)) + const packageManager = isPnpm ? 'pnpm' : isYarn ? 'yarn' : isNpm ? 'npm' : null if (!packageManager) { console.error('Cannot detect Package Manager in', rootDir) process.exit(1) @@ -42,7 +44,7 @@ export default defineNuxtCommand({ if (args.force || args.f) { consola.info('Removing lock-file and node_modules...') await Promise.all([ - fsp.rm(isYarn ? yarnLock : npmLock), + fsp.rm(isPnpm ? pnpmLock : isYarn ? yarnLock : npmLock), fsp.rmdir('node_modules', { recursive: true }) ]) execSync(`${packageManager} install`, { stdio: 'inherit' })