@@ -7,7 +7,7 @@ import { afterEach, beforeAll, expect, test } from 'vitest'
77const CLI_PATH = join ( __dirname , '..' )
88
99const projectName = 'electron-vite-app'
10- const generatePath = join ( __dirname , projectName )
10+ const genPath = join ( __dirname , projectName )
1111
1212const run = (
1313 args : string [ ] ,
@@ -18,23 +18,40 @@ const run = (
1818
1919const createNonEmptyDir = ( ) => {
2020 // Create the temporary directory
21- fs . mkdirpSync ( generatePath )
21+ fs . mkdirpSync ( genPath )
2222
2323 // Create a package.json file
24- const pkgJson = join ( generatePath , 'package.json' )
24+ const pkgJson = join ( genPath , 'package.json' )
2525 fs . writeFileSync ( pkgJson , '{ "foo": "bar" }' )
2626}
2727
28- beforeAll ( ( ) => fs . remove ( generatePath ) )
29- afterEach ( ( ) => fs . remove ( generatePath ) )
28+ beforeAll ( ( ) => fs . remove ( genPath ) )
29+ afterEach ( ( ) => fs . remove ( genPath ) )
3030
3131test ( 'prompts for the project name if none supplied' , ( ) => {
3232 const { stdout } = run ( [ ] )
3333 expect ( stdout ) . toContain ( 'Project name:' )
3434} )
3535
36- test ( 'prompts for project template if none supplied when target dir is current directory' , ( ) => {
37- fs . mkdirpSync ( generatePath )
38- const { stdout } = run ( [ '.' ] , { cwd : generatePath } )
36+ test ( 'prompts for the framework if none supplied when target dir is current directory' , ( ) => {
37+ fs . mkdirpSync ( genPath )
38+ const { stdout } = run ( [ '.' ] , { cwd : genPath } )
3939 expect ( stdout ) . toContain ( 'Project template:' )
4040} )
41+
42+ test ( 'prompts for the framework if none supplied' , ( ) => {
43+ const { stdout } = run ( [ projectName ] )
44+ expect ( stdout ) . toContain ( 'Project template:' )
45+ } )
46+
47+ test ( 'asks to overwrite non-empty target directory' , ( ) => {
48+ createNonEmptyDir ( )
49+ const { stdout } = run ( [ projectName ] , { cwd : __dirname } )
50+ expect ( stdout ) . toContain ( `Target directory "${ projectName } " is not empty.` )
51+ } )
52+
53+ test ( 'asks to overwrite non-empty current directory' , ( ) => {
54+ createNonEmptyDir ( )
55+ const { stdout } = run ( [ '.' ] , { cwd : genPath } )
56+ expect ( stdout ) . toContain ( `Current directory is not empty.` )
57+ } )
0 commit comments