Skip to content

Commit

Permalink
feat(create-vite): allow overwrite in command line (#15808)
Browse files Browse the repository at this point in the history
Co-authored-by: bluwy <bjornlu.dev@gmail.com>
  • Loading branch information
raelgc and bluwy committed Feb 8, 2024
1 parent 1f84cae commit 1882c73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/create-vite/__tests__/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,9 @@ test('works with the -t alias', () => {
expect(stdout).toContain(`Scaffolding project in ${genPath}`)
expect(templateFiles).toEqual(generatedFiles)
})

test('accepts command line override for --overwrite', () => {
createNonEmptyDir()
const { stdout } = run(['.', '--overwrite', 'ignore'], { cwd: genPath })
expect(stdout).not.toContain(`Current directory is not empty.`)
})
4 changes: 4 additions & 0 deletions packages/create-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ async function init() {
'projectName' | 'overwrite' | 'packageName' | 'framework' | 'variant'
>

prompts.override({
overwrite: argv.overwrite,
})

try {
result = await prompts(
[
Expand Down

0 comments on commit 1882c73

Please sign in to comment.