mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +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 { cyan } from 'colorette'
|
||||||
|
import { showHelp } from '../utils/help'
|
||||||
import { commands, defineNuxtCommand } from './index'
|
import { commands, defineNuxtCommand } from './index'
|
||||||
|
|
||||||
export default defineNuxtCommand({
|
export default defineNuxtCommand({
|
||||||
@ -13,5 +14,8 @@ export default defineNuxtCommand({
|
|||||||
sections.push(`Usage: ${cyan(`npx nuxi ${Object.keys(commands).join('|')} [args]`)}`)
|
sections.push(`Usage: ${cyan(`npx nuxi ${Object.keys(commands).join('|')} [args]`)}`)
|
||||||
|
|
||||||
console.log(sections.join('\n\n') + '\n')
|
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 mri from 'mri'
|
||||||
import { red, cyan } from 'colorette'
|
import { red } from 'colorette'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { checkEngines } from './utils/engines'
|
import { checkEngines } from './utils/engines'
|
||||||
import { commands, Command, NuxtCommand } from './commands'
|
import { commands, Command, NuxtCommand } from './commands'
|
||||||
@ -14,23 +14,20 @@ async function _main () {
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let command = args._.shift() || 'usage'
|
const command = args._.shift() || 'usage'
|
||||||
|
|
||||||
showBanner(command === 'dev' && args.clear !== false)
|
showBanner(command === 'dev' && args.clear !== false)
|
||||||
|
|
||||||
if (!(command in commands)) {
|
if (!(command in commands)) {
|
||||||
console.log('\n' + red('Invalid command ' + command))
|
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
|
// Check Node.js version in background
|
||||||
setTimeout(() => { checkEngines() }, 1000)
|
setTimeout(() => { checkEngines() }, 1000)
|
||||||
|
|
||||||
if (command === 'usage') {
|
|
||||||
console.log(`\nUsage: ${cyan(`npx nuxi ${Object.keys(commands).join('|')} [args]`)}\n`)
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// @ts-ignore default.default is hotfix for #621
|
// @ts-ignore default.default is hotfix for #621
|
||||||
const cmd = await commands[command as Command]() as NuxtCommand
|
const cmd = await commands[command as Command]() as NuxtCommand
|
||||||
|
Loading…
Reference in New Issue
Block a user