File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2+ import { existsSync } from 'fs' ;
23import { dirname , join } from 'path' ;
34import { createCLI } from 'tinycreate' ;
45import { fileURLToPath } from 'url' ;
@@ -14,8 +15,16 @@ const config = {
1415 name : 'projectName' ,
1516 message : 'Project name:' ,
1617 initial : 'my-tinybase-app' ,
17- validate : ( value : string ) =>
18- value . length > 0 ? true : 'Project name is required' ,
18+ validate : ( value : string ) => {
19+ if ( value . length === 0 ) {
20+ return 'Project name is required' ;
21+ }
22+ const targetPath = join ( process . cwd ( ) , value ) ;
23+ if ( existsSync ( targetPath ) ) {
24+ return `Directory "${ value } " already exists. Please choose a different name.` ;
25+ }
26+ return true ;
27+ } ,
1928 } ,
2029 {
2130 type : 'select' as const ,
You can’t perform that action at this time.
0 commit comments