File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import commander from "commander";
13
13
import path from "path" ;
14
14
import { Options , SAO } from "sao" ;
15
15
import { cleanupSync , track } from "temp" ;
16
+ import validate from "validate-npm-package-name" ;
16
17
import packageData from "../package.json" ;
17
18
18
19
const generator = path . resolve ( __dirname , "./" ) ;
@@ -178,9 +179,14 @@ const cli = async (): Promise<void> => {
178
179
presetAnswers = get_random_answers ( promptsAndChoices ) ;
179
180
}
180
181
182
+ const validProjectDir = ! ! projectDir && ! validate ( projectDir ) . errors ;
183
+
181
184
const withAnswers =
182
185
presetAnswers && Object . keys ( presetAnswers ) . length > 0
183
- ? true
186
+ ? {
187
+ ...presetAnswers ,
188
+ ...( validProjectDir ? { name : projectDir } : { } ) ,
189
+ }
184
190
: undefined ;
185
191
186
192
const sao = new SAO ( {
You can’t perform that action at this time.
0 commit comments