Skip to content

Commit

Permalink
feat(cli/init): allow passing target dir as command argument (#3948)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd authored Jun 9, 2024
1 parent 1e8bb48 commit 99053ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
11 changes: 7 additions & 4 deletions src/node/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 99053ba

Please sign in to comment.