feat(cli/init): allow passing target dir as command argument (#3948)

pull/3291/head
Divyansh Singh 3 weeks ago committed by GitHub
parent 1e8bb48bc2
commit 99053baea7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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') {

@ -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({

Loading…
Cancel
Save