Commit 6dc114c 1 parent 5b8b582 commit 6dc114c Copy full SHA for 6dc114c
File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ const combinedArguments = rcResult
82
82
83
83
program . parse ( combinedArguments )
84
84
85
- // filter out undefined program options and combine with config file options
85
+ // filter out undefined program options and combine cli options with config file options
86
86
const options = {
87
87
...rcResult && Object . keys ( rcResult . config ) . length > 0
88
88
? { rcConfigPath : rcResult . filePath }
@@ -93,4 +93,6 @@ const options = {
93
93
cli : true ,
94
94
}
95
95
96
+ // NOTE: Options handling and defaults go in initOptions in index.js
97
+
96
98
ncu . run ( options )
Original file line number Diff line number Diff line change @@ -182,8 +182,8 @@ const cliOptions = [
182
182
long : 'packageManager' ,
183
183
short : 'p' ,
184
184
arg : 'name' ,
185
- description : 'npm, yarn' ,
186
- default : 'npm'
185
+ // manual default to allow overriding auto yarn detection
186
+ description : 'npm, yarn (default: "npm") '
187
187
} ,
188
188
{
189
189
long : 'pre' ,
Original file line number Diff line number Diff line change @@ -297,6 +297,13 @@ function initOptions(options) {
297
297
...options . ownerChanged ? [ 'ownerChanged' ] : [ ]
298
298
]
299
299
300
+ // autodetect yarn
301
+ const files = fs . readdirSync ( options . cwd || '.' )
302
+ const autoYarn = ! options . packageManager && files . includes ( 'yarn.lock' ) && ! files . includes ( 'package-lock.json' )
303
+ if ( autoYarn ) {
304
+ print ( options , 'Using yarn' )
305
+ }
306
+
300
307
return {
301
308
...options ,
302
309
...options . deep ? { packageFile : `${ deepPatternPrefix } ${ getPackageFileName ( options ) } ` } : null ,
@@ -314,6 +321,7 @@ function initOptions(options) {
314
321
target,
315
322
// imply upgrade in interactive mode when json is not specified as the output
316
323
...options . interactive && options . upgrade === undefined ? { upgrade : ! json } : null ,
324
+ ...! options . packageManager && { packageManager : autoYarn ? 'yarn' : 'npm' } ,
317
325
}
318
326
}
319
327
You can’t perform that action at this time.
0 commit comments