mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(cli): enable usage
command (#2079)
This commit is contained in:
parent
d68318f9d5
commit
2a29c6aa1a
@ -1,4 +1,5 @@
|
||||
import { cyan } from 'colorette'
|
||||
import { showHelp } from '../utils/help'
|
||||
import { commands, defineNuxtCommand } from './index'
|
||||
|
||||
export default defineNuxtCommand({
|
||||
@ -13,5 +14,8 @@ export default defineNuxtCommand({
|
||||
sections.push(`Usage: ${cyan(`npx nuxi ${Object.keys(commands).join('|')} [args]`)}`)
|
||||
|
||||
console.log(sections.join('\n\n') + '\n')
|
||||
|
||||
// Reuse the same wording as in `-h` commands
|
||||
showHelp({})
|
||||
}
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
import mri from 'mri'
|
||||
import { red, cyan } from 'colorette'
|
||||
import { red } from 'colorette'
|
||||
import consola from 'consola'
|
||||
import { checkEngines } from './utils/engines'
|
||||
import { commands, Command, NuxtCommand } from './commands'
|
||||
@ -14,23 +14,20 @@ async function _main () {
|
||||
]
|
||||
})
|
||||
// @ts-ignore
|
||||
let command = args._.shift() || 'usage'
|
||||
const command = args._.shift() || 'usage'
|
||||
|
||||
showBanner(command === 'dev' && args.clear !== false)
|
||||
|
||||
if (!(command in commands)) {
|
||||
console.log('\n' + red('Invalid command ' + command))
|
||||
command = 'usage'
|
||||
|
||||
await commands.usage().then(r => r.invoke())
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Check Node.js version in background
|
||||
setTimeout(() => { checkEngines() }, 1000)
|
||||
|
||||
if (command === 'usage') {
|
||||
console.log(`\nUsage: ${cyan(`npx nuxi ${Object.keys(commands).join('|')} [args]`)}\n`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
try {
|
||||
// @ts-ignore default.default is hotfix for #621
|
||||
const cmd = await commands[command as Command]() as NuxtCommand
|
||||
|
Loading…
Reference in New Issue
Block a user