mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 10:04:05 +00:00
14 lines
421 B
TypeScript
14 lines
421 B
TypeScript
import mri from 'mri'
|
|
import type { Command, NuxtCommand } from './commands'
|
|
import { commands } from './commands'
|
|
|
|
export async function runCommand (command: string, argv = process.argv.slice(2)) {
|
|
const args = mri(argv)
|
|
args.clear = false // used by dev
|
|
const cmd = await commands[command as Command]() as NuxtCommand
|
|
if (!cmd) {
|
|
throw new Error(`Invalid command ${command}`)
|
|
}
|
|
await cmd.invoke(args)
|
|
}
|