From 1e5d54cdf0ae79548746056e0e9d806b99507af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?= Date: Sat, 4 Jan 2025 12:57:44 +0100 Subject: [PATCH] feat(module): add --dev argument --- src/commands/module/add.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/module/add.ts b/src/commands/module/add.ts index 5e0ef4d3e..67b5cd5ff 100644 --- a/src/commands/module/add.ts +++ b/src/commands/module/add.ts @@ -55,6 +55,10 @@ export default defineCommand({ type: 'boolean', description: 'Skip nuxt.config.ts update', }, + dev: { + type: 'boolean', + description: 'Install modules as dev dependencies', + }, }, async setup(ctx) { const cwd = resolve(ctx.args.cwd) @@ -89,10 +93,10 @@ export default defineCommand({ }) // -- Internal Utils -- -async function addModule(r: ResolvedModule[], { skipInstall, skipConfig, cwd }: { skipInstall: boolean, skipConfig: boolean, cwd: string }, projectPkg: any) { +async function addModule(r: ResolvedModule[], { skipInstall, skipConfig, cwd, dev }: { skipInstall: boolean, skipConfig: boolean, cwd: string, dev: boolean }, projectPkg: any) { // Add npm dependency if (!skipInstall) { - const isDev = Boolean(projectPkg.devDependencies?.nuxt) + const isDev = Boolean(projectPkg.devDependencies?.nuxt) || dev consola.info(`Installing \`${r.map(x => x.pkg).join(', ')}\`${isDev ? ' development' : ''} dep(s)`) const res = await addDependency(r.map(x => x.pkg), { cwd, dev: isDev, installPeerDependencies: true }).catch( (error) => {