@@ -230,27 +230,45 @@ export default [\n${exportContent}];`;
230
230
* @returns {void }
231
231
*/
232
232
async output ( ) {
233
- const packageManager = ( await enquirer . prompt ( {
234
- type : "select" ,
235
- name : "packageManager" ,
236
- message : "Which package manager do you want to use?" ,
237
- initial : 0 ,
238
- choices : [ "npm" , "yarn" , "pnpm" , "bun" ]
239
- } ) ) . packageManager ;
240
-
241
- installSyncSaveDev ( this . result . devDependencies , packageManager ) ;
233
+ const installDevDeps = ( await enquirer . prompt ( {
234
+ type : "toggle" ,
235
+ name : "executeInstallation" ,
236
+ message : "Would you like to install them now?" ,
237
+ enabled : "Yes" ,
238
+ disabled : "No" ,
239
+ initial : 1
240
+ } ) ) . executeInstallation ;
242
241
243
242
const configPath = path . join ( this . cwd , this . result . configFilename ) ;
244
243
245
- await writeFile ( configPath , this . result . configContent ) ;
246
-
247
- // import("eslint") won't work in some cases.
248
- // refs: https://github.com/eslint/create-config/issues/8, https://github.com/eslint/create-config/issues/12
249
- const eslintBin = path . join ( this . packageJsonPath , "../node_modules/eslint/bin/eslint.js" ) ;
250
- const result = spawnSync ( process . execPath , [ eslintBin , "--fix" , "--quiet" , configPath ] , { encoding : "utf8" } ) ;
244
+ if ( installDevDeps === true ) {
245
+ const packageManager = ( await enquirer . prompt ( {
246
+ type : "select" ,
247
+ name : "packageManager" ,
248
+ message : "Which package manager do you want to use?" ,
249
+ initial : 0 ,
250
+ choices : [ "npm" , "yarn" , "pnpm" , "bun" ]
251
+ } ) ) . packageManager ;
252
+
253
+ log . info ( `Installing ${ this . result . devDependencies . join ( ", " ) } ` ) ;
254
+ installSyncSaveDev ( this . result . devDependencies , packageManager ) ;
255
+ await writeFile ( configPath , this . result . configContent ) ;
256
+
257
+ // import("eslint") won't work in some cases.
258
+ // refs: https://github.com/eslint/create-config/issues/8, https://github.com/eslint/create-config/issues/12
259
+ const eslintBin = path . join ( this . packageJsonPath , "../node_modules/eslint/bin/eslint.js" ) ;
260
+ const result = spawnSync ( process . execPath , [ eslintBin , "--fix" , "--quiet" , configPath ] , { encoding : "utf8" } ) ;
261
+
262
+ if ( result . error || result . status !== 0 ) {
263
+ log . error ( "A config file was generated, but the config file itself may not follow your linting rules." ) ;
264
+ } else {
265
+ log . info ( `Successfully created ${ configPath } file.` ) ;
266
+ }
267
+ } else {
268
+ await writeFile ( configPath , this . result . configContent ) ;
251
269
252
- if ( result . error || result . status !== 0 ) {
253
- log . error ( "A config file was generated, but the config file itself may not follow your linting rules." ) ;
270
+ log . info ( `Successfully created ${ configPath } file.` ) ;
271
+ log . info ( `You will need to install the following dependencies yourself: ${ this . result . devDependencies . join ( ", " ) } ` ) ;
254
272
}
255
273
}
256
274
}
0 commit comments