mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
feat(cli): add placeholder generate command (#738)
This commit is contained in:
parent
d1e0af928e
commit
096b0e3305
26
packages/nuxi/src/commands/generate.ts
Normal file
26
packages/nuxi/src/commands/generate.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { resolve } from 'pathe'
|
||||
import { isNuxt3 } from '@nuxt/kit'
|
||||
import { importModule } from '../utils/cjs'
|
||||
|
||||
import { defineNuxtCommand } from './index'
|
||||
|
||||
export default defineNuxtCommand({
|
||||
meta: {
|
||||
name: 'generate',
|
||||
usage: 'npx nuxi generate [rootDir]',
|
||||
description: ''
|
||||
},
|
||||
async invoke (args) {
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
||||
const rootDir = resolve(args._[0] || '.')
|
||||
|
||||
const { loadNuxt } = await importModule('@nuxt/kit', rootDir) as typeof import('@nuxt/kit')
|
||||
const nuxt = await loadNuxt({ rootDir })
|
||||
|
||||
if (isNuxt3(nuxt)) {
|
||||
throw new Error('`nuxt generate` is not supported in Nuxt 3. Please follow this RFC: https://git.io/JKfvx')
|
||||
} else {
|
||||
throw new Error('Please use `nuxt generate` for Nuxt 2 instead of `nuxi generate`')
|
||||
}
|
||||
}
|
||||
})
|
@ -5,6 +5,7 @@ const _rDefault = r => r.default || r
|
||||
export const commands = {
|
||||
dev: () => import('./dev').then(_rDefault),
|
||||
build: () => import('./build').then(_rDefault),
|
||||
generate: () => import('./generate').then(_rDefault),
|
||||
prepare: () => import('./prepare').then(_rDefault),
|
||||
usage: () => import('./usage').then(_rDefault),
|
||||
info: () => import('./info').then(_rDefault),
|
||||
|
Loading…
Reference in New Issue
Block a user