diff --git a/src/node/cli.ts b/src/node/cli.ts index 7c452138..4c72a27c 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -54,7 +54,7 @@ if (!command || command === 'dev') { }) } else if (command === 'init') { createLogger().info('', { clear: true }) - init() + init(argv.root) } else { logVersion() if (command === 'build') { diff --git a/src/node/init/init.ts b/src/node/init/init.ts index 5b62eeaf..a1ec8b5c 100644 --- a/src/node/init/init.ts +++ b/src/node/init/init.ts @@ -33,19 +33,22 @@ const getPackageManger = () => { return name.split('/')[0] } -export async function init() { +export async function init(root: string | undefined) { intro(bold(cyan('Welcome to VitePress!'))) const options: ScaffoldOptions = await group( { - root: () => - text({ + root: async () => { + if (root) return root + + return text({ message: 'Where should VitePress initialize the config?', initialValue: './', validate(value) { // TODO make sure directory is inside } - }), + }) + }, title: () => text({