1- import cosmiconfig from 'cosmiconfig'
1+ import { cosmiconfig , cosmiconfigSync } from 'cosmiconfig'
22
33export const DEFAULT_CONFIG = {
44 h2xConfig : null ,
@@ -25,6 +25,12 @@ const explorer = cosmiconfig('svgr', {
2525 rcExtensions : true ,
2626} )
2727
28+ const explorerSync = cosmiconfigSync ( 'svgr' , {
29+ sync : true ,
30+ cache : true ,
31+ rcExtensions : true ,
32+ } )
33+
2834export async function resolveConfig ( searchFrom , configFile ) {
2935 if ( configFile == null ) {
3036 const result = await explorer . search ( searchFrom )
@@ -36,10 +42,10 @@ export async function resolveConfig(searchFrom, configFile) {
3642
3743resolveConfig . sync = ( searchFrom , configFile ) => {
3844 if ( configFile == null ) {
39- const result = explorer . searchSync ( searchFrom )
45+ const result = explorerSync . search ( searchFrom )
4046 return result ? result . config : null
4147 }
42- const result = explorer . loadSync ( configFile )
48+ const result = explorerSync . load ( configFile )
4349 return result ? result . config : null
4450}
4551
@@ -49,7 +55,7 @@ export async function resolveConfigFile(filePath) {
4955}
5056
5157resolveConfigFile . sync = filePath => {
52- const result = explorer . searchSync ( filePath )
58+ const result = explorerSync . search ( filePath )
5359 return result ? result . filepath : null
5460}
5561
0 commit comments