Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/nuxi/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { installDependencies } from 'nypm'
import { relative, resolve } from 'pathe'
import { x } from 'tinyexec'

import { runCommand } from '../run'
import { logger } from '../utils/logger'
import { cwdArgs } from './_shared'

Expand Down Expand Up @@ -74,6 +75,12 @@ export default defineCommand({
type: 'string',
description: 'Package manager choice (npm, pnpm, yarn, bun)',
},
modules: {
type: 'string',
required: false,
description: 'Nuxt modules to install (comma separated without spaces)',
alias: 'M',
},
},
async run(ctx) {
const cwd = resolve(ctx.args.cwd)
Expand Down Expand Up @@ -205,6 +212,12 @@ export default defineCommand({
}
}

// Add modules when -M flag is provided
const modules = !ctx.args.modules ? [] : ctx.args.modules.split(',').map(module => module.trim()).filter(Boolean)
if (modules.length > 0) {
await runCommand('module', ['add', ...modules])
}

// Display next steps
logger.log(
`\n✨ Nuxt project has been created with the \`${template.name}\` template. Next steps:`,
Expand Down
1 change: 1 addition & 0 deletions packages/nuxi/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ globalThis.__nuxt_cli__ = globalThis.__nuxt_cli__ || {

export const runMain = () => _runMain(main)

// To provide subcommands call it as `runCommand(<command>, [<subcommand>, ...])`
export async function runCommand(
name: string,
argv: string[] = process.argv.slice(2),
Expand Down
Loading