File tree Expand file tree Collapse file tree 5 files changed +22
-24
lines changed
Expand file tree Collapse file tree 5 files changed +22
-24
lines changed Original file line number Diff line number Diff line change 2828 "app-root-path" : " ^2.0.1" ,
2929 "chalk" : " ^2.3.1" ,
3030 "commander" : " ^2.14.1" ,
31- "cosmiconfig" : " ^4 .0.0 " ,
31+ "cosmiconfig" : " ^5 .0.2 " ,
3232 "debug" : " ^3.1.0" ,
3333 "dedent" : " ^0.7.0" ,
3434 "execa" : " ^0.9.0" ,
Original file line number Diff line number Diff line change @@ -18,20 +18,28 @@ if (process.stdout.isTTY) {
1818
1919const errConfigNotFound = new Error ( 'Config could not be found' )
2020
21+ function loadConfig ( configPath ) {
22+ const explorer = cosmiconfig ( 'lint-staged' , {
23+ searchPlaces : [
24+ 'package.json' ,
25+ `.lintstagedrc` ,
26+ `.lintstagedrc.json` ,
27+ `.lintstagedrc.yaml` ,
28+ `.lintstagedrc.yml` ,
29+ `lint-staged.config.js`
30+ ]
31+ } )
32+
33+ return configPath ? explorer . load ( configPath ) : explorer . search ( )
34+ }
35+
2136/**
2237 * Root lint-staged function that is called from .bin
2338 */
2439module . exports = function lintStaged ( logger = console , configPath , debugMode ) {
2540 debug ( 'Loading config using `cosmiconfig`' )
2641
27- const explorer = cosmiconfig ( 'lint-staged' , {
28- configPath,
29- rc : '.lintstagedrc' ,
30- rcExtensions : true
31- } )
32-
33- return explorer
34- . load ( )
42+ return loadConfig ( configPath )
3543 . then ( result => {
3644 if ( result == null ) throw errConfigNotFound
3745
Original file line number Diff line number Diff line change 11const actual = require . requireActual ( 'cosmiconfig' )
2- const mock = jest . genMockFromModule ( 'cosmiconfig' )
32
43function cosmiconfig ( name , options ) {
5- if ( options . configPath ) {
6- return actual ( name , options )
7- }
8-
9- return mock ( name , options )
4+ return actual ( name , options )
105}
116
127module . exports = jest . fn ( cosmiconfig )
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const replaceSerializer = (from, to) => ({
1010
1111const mockCosmiconfigWith = result => {
1212 cosmiconfig . mockImplementationOnce ( ( ) => ( {
13- load : ( ) => Promise . resolve ( result )
13+ search : ( ) => Promise . resolve ( result )
1414 } ) )
1515}
1616
Original file line number Diff line number Diff line change 11491149 version "1.0.2"
11501150 resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
11511151
1152- cosmiconfig@^4 .0.0 :
1153- version "4 .0.0 "
1154- resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-4 .0.0 .tgz#760391549580bbd2df1e562bc177b13c290972dc "
1152+ cosmiconfig@^5 .0.2 :
1153+ version "5 .0.2 "
1154+ resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5 .0.2 .tgz#03f8965ae4675317a0015b4a5a48a470d9baeada "
11551155 dependencies :
11561156 is-directory "^0.3.1"
11571157 js-yaml "^3.9.0"
11581158 parse-json "^4.0.0"
1159- require-from-string "^2.0.1"
11601159
11611160cross-spawn@^5.0.1, cross-spawn@^5.1.0 :
11621161 version "5.1.0"
@@ -4049,10 +4048,6 @@ require-directory@^2.1.1:
40494048 version "2.1.1"
40504049 resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
40514050
4052- require-from-string@^2.0.1 :
4053- version "2.0.1"
4054- resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.1.tgz#c545233e9d7da6616e9d59adfb39fc9f588676ff"
4055-
40564051require-main-filename@^1.0.1 :
40574052 version "1.0.1"
40584053 resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
You can’t perform that action at this time.
0 commit comments