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') { } else if (command === 'init') {
createLogger().info('', { clear: true }) createLogger().info('', { clear: true })
init() init(argv.root)
} else { } else {
logVersion() logVersion()
if (command === 'build') { if (command === 'build') {

@ -33,19 +33,22 @@ const getPackageManger = () => {
return name.split('/')[0] return name.split('/')[0]
} }
export async function init() { export async function init(root: string | undefined) {
intro(bold(cyan('Welcome to VitePress!'))) intro(bold(cyan('Welcome to VitePress!')))
const options: ScaffoldOptions = await group( const options: ScaffoldOptions = await group(
{ {
root: () => root: async () => {
text({ if (root) return root
return text({
message: 'Where should VitePress initialize the config?', message: 'Where should VitePress initialize the config?',
initialValue: './', initialValue: './',
validate(value) { validate(value) {
// TODO make sure directory is inside // TODO make sure directory is inside
} }
}), })
},
title: () => title: () =>
text({ text({

Loading…
Cancel
Save