mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
fix(nuxi): ensure nuxi upgrade
runs in rootDir (#6707)
This commit is contained in:
parent
c9837dca48
commit
e93f88c1e4
@ -1,19 +1,17 @@
|
|||||||
import { execSync } from 'node:child_process'
|
import { execSync } from 'node:child_process'
|
||||||
import { promises as fsp } from 'node:fs'
|
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
import { resolveModule } from '../utils/cjs'
|
import { readPackageJSON } from 'pkg-types'
|
||||||
import { getPackageManager, packageManagerLocks } from '../utils/packageManagers'
|
import { getPackageManager, packageManagerLocks } from '../utils/packageManagers'
|
||||||
import { rmRecursive, touchFile } from '../utils/fs'
|
import { rmRecursive, touchFile } from '../utils/fs'
|
||||||
import { cleanupNuxtDirs } from '../utils/nuxt'
|
import { cleanupNuxtDirs } from '../utils/nuxt'
|
||||||
import { defineNuxtCommand } from './index'
|
import { defineNuxtCommand } from './index'
|
||||||
|
|
||||||
async function getNuxtVersion (paths: string | string[]): Promise<string|null> {
|
async function getNuxtVersion (path: string): Promise<string|null> {
|
||||||
try {
|
try {
|
||||||
const pkgJson = resolveModule('nuxt/package.json', paths)
|
const pkg = await readPackageJSON('nuxt', { url: path })
|
||||||
const pkg = pkgJson && JSON.parse(await fsp.readFile(pkgJson, 'utf8'))
|
|
||||||
if (!pkg.version) {
|
if (!pkg.version) {
|
||||||
consola.warn('Cannot find any installed nuxt versions in ', paths)
|
consola.warn('Cannot find any installed nuxt versions in ', path)
|
||||||
}
|
}
|
||||||
return pkg.version || null
|
return pkg.version || null
|
||||||
} catch {
|
} catch {
|
||||||
@ -53,7 +51,7 @@ export default defineNuxtCommand({
|
|||||||
|
|
||||||
// Install latest rc
|
// Install latest rc
|
||||||
consola.info('Installing latest Nuxt 3 RC...')
|
consola.info('Installing latest Nuxt 3 RC...')
|
||||||
execSync(`${packageManager} ${packageManager === 'yarn' ? 'add' : 'install'} -D nuxt@rc`, { stdio: 'inherit' })
|
execSync(`${packageManager} ${packageManager === 'yarn' ? 'add' : 'install'} -D nuxt@rc`, { stdio: 'inherit', cwd: rootDir })
|
||||||
|
|
||||||
// Cleanup after upgrade
|
// Cleanup after upgrade
|
||||||
await cleanupNuxtDirs(rootDir)
|
await cleanupNuxtDirs(rootDir)
|
||||||
|
Loading…
Reference in New Issue
Block a user