From 1882c734b1aa3199d12988f06591b71ed5d5af27 Mon Sep 17 00:00:00 2001 From: Rael Gugelmin Cunha Date: Thu, 8 Feb 2024 06:19:38 -0300 Subject: [PATCH] feat(create-vite): allow overwrite in command line (#15808) Co-authored-by: bluwy --- packages/create-vite/__tests__/cli.spec.ts | 6 ++++++ packages/create-vite/src/index.ts | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/packages/create-vite/__tests__/cli.spec.ts b/packages/create-vite/__tests__/cli.spec.ts index 0db7338415e75a..e34d4e14f6e4cf 100644 --- a/packages/create-vite/__tests__/cli.spec.ts +++ b/packages/create-vite/__tests__/cli.spec.ts @@ -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.`) +}) diff --git a/packages/create-vite/src/index.ts b/packages/create-vite/src/index.ts index 06fab482ccbff2..53d2a65b1c57af 100755 --- a/packages/create-vite/src/index.ts +++ b/packages/create-vite/src/index.ts @@ -253,6 +253,10 @@ async function init() { 'projectName' | 'overwrite' | 'packageName' | 'framework' | 'variant' > + prompts.override({ + overwrite: argv.overwrite, + }) + try { result = await prompts( [