diff --git a/packages/nuxi/src/commands/dev.ts b/packages/nuxi/src/commands/dev.ts index 167dddf22f..bd27389d43 100644 --- a/packages/nuxi/src/commands/dev.ts +++ b/packages/nuxi/src/commands/dev.ts @@ -22,7 +22,7 @@ export default defineNuxtCommand({ usage: 'npx nuxi dev [rootDir] [--dotenv] [--log-level] [--clipboard] [--open, -o] [--port, -p] [--host, -h] [--https] [--ssl-cert] [--ssl-key]', description: 'Run nuxt development server' }, - async invoke (args) { + async invoke (args, options = {}) { overrideEnv('development') const { listen } = await import('listhen') @@ -50,7 +50,8 @@ export default defineNuxtCommand({ cwd: rootDir, overrides: { dev: true, - logLevel: args['log-level'] + logLevel: args['log-level'], + ...(options.overrides || {}) } }) @@ -96,7 +97,8 @@ export default defineNuxtCommand({ dev: true, ready: false, overrides: { - logLevel: args['log-level'] + logLevel: args['log-level'], + ...(options.overrides || {}) } }) diff --git a/packages/nuxi/src/commands/index.ts b/packages/nuxi/src/commands/index.ts index b450945bf3..36019a785c 100644 --- a/packages/nuxi/src/commands/index.ts +++ b/packages/nuxi/src/commands/index.ts @@ -37,7 +37,7 @@ export interface NuxtCommandMeta { export type CLIInvokeResult = void | 'error' | 'wait' export interface NuxtCommand { - invoke(args: Argv): Promise | CLIInvokeResult + invoke(args: Argv, options?: Record): Promise | CLIInvokeResult meta: NuxtCommandMeta } diff --git a/packages/nuxi/src/run.ts b/packages/nuxi/src/run.ts index 4389c0f7f6..6640fe6b7d 100644 --- a/packages/nuxi/src/run.ts +++ b/packages/nuxi/src/run.ts @@ -2,12 +2,12 @@ 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)) { +export async function runCommand (command: string, argv = process.argv.slice(2), options: Record = {}) { 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) + await cmd.invoke(args, options) }