File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ function prompt(question, defaultAnswer) {
2626 } ) ;
2727}
2828
29+ function getDirName ( defaultDirName ) {
30+ let dirName = args . _ [ 0 ] ?? defaultDirName ;
31+ if ( fs . existsSync ( dirName ) ) dirName += `-${ timestamp } ` ;
32+ return dirName ;
33+ }
34+
2935async function installDependencies ( dirName ) {
3036 console . log ( `Installing dependencies ...` ) ;
3137 await run ( `cd ${ dirName } && npm install` ) ;
@@ -68,7 +74,7 @@ const timestamp = Math.round(new Date().getTime() / 1000);
6874
6975async function cloneStarter ( ) {
7076 // Set references
71- const dirName = args . _ [ 0 ] ?? ` ${ config . defaults . dirName } - ${ timestamp } ` ;
77+ const dirName = getDirName ( config . defaults . dirName ) ;
7278
7379 // Clone repo
7480 const cloneCommand = `git clone --depth=1 ${ starter . repoUrl } ${ dirName } ` ;
@@ -92,7 +98,7 @@ Follow the instructions for getting Started here:
9298/* --- New Project from Example --- */
9399
94100async function cloneExample ( ) {
95- const dirName = args . _ [ 0 ] ?? ` ${ args . example } - ${ timestamp } ` ;
101+ const dirName = getDirName ( args . example ) ;
96102 const tmpDir = `__tmp${ timestamp } __` ;
97103 console . log ( `\nCreating new project in ${ dirName } ...` ) ;
98104
You can’t perform that action at this time.
0 commit comments