fix(nuxi): generate types with nuxi generate (#1625)

This commit is contained in:
Daniel Roe 2021-11-02 09:31:35 +00:00 committed by GitHub
parent 288e771205
commit 348c82d55a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import { resolve } from 'pathe'
import { isNuxt3 } from '@nuxt/kit'
import { loadKit } from '../utils/kit'
import { writeTypes } from '../utils/prepare'
import { defineNuxtCommand } from './index'
export default defineNuxtCommand({
@ -16,13 +17,16 @@ export default defineNuxtCommand({
const rootDir = resolve(args._[0] || '.')
const { loadNuxt } = await loadKit(rootDir)
const nuxt = await loadNuxt({ rootDir })
const nuxt = await loadNuxt({ rootDir, config: { _export: true } })
if (isNuxt3(nuxt)) {
throw new Error('`nuxt generate` is not supported in Nuxt 3. Please follow this RFC: https://git.io/JKfvx')
} else {
// Generate types and close nuxt instance
await writeTypes(nuxt)
await nuxt.close()
// Forwards argv to `nuxt generate`
await execa('npx nuxt', process.argv.slice(2), { stdio: 'inherit' })
await execa('npx', ['nuxt', ...process.argv.slice(2)], { stdio: 'inherit' })
}
}
})