Skip to content

Commit 99053ba

Browse files
authored
feat(cli/init): allow passing target dir as command argument (#3948)
1 parent 1e8bb48 commit 99053ba

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Diff for: src/node/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if (!command || command === 'dev') {
5454
})
5555
} else if (command === 'init') {
5656
createLogger().info('', { clear: true })
57-
init()
57+
init(argv.root)
5858
} else {
5959
logVersion()
6060
if (command === 'build') {

Diff for: src/node/init/init.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,22 @@ const getPackageManger = () => {
3333
return name.split('/')[0]
3434
}
3535

36-
export async function init() {
36+
export async function init(root: string | undefined) {
3737
intro(bold(cyan('Welcome to VitePress!')))
3838

3939
const options: ScaffoldOptions = await group(
4040
{
41-
root: () =>
42-
text({
41+
root: async () => {
42+
if (root) return root
43+
44+
return text({
4345
message: 'Where should VitePress initialize the config?',
4446
initialValue: './',
4547
validate(value) {
4648
// TODO make sure directory is inside
4749
}
48-
}),
50+
})
51+
},
4952

5053
title: () =>
5154
text({

0 commit comments

Comments
 (0)