(configFile?: string, workingDir?: string)
| 74 | configureV3ClientDefaults(); |
| 75 | |
| 76 | export const tryToReadInsoConfigFile = async (configFile?: string, workingDir?: string) => { |
| 77 | try { |
| 78 | const explorer = await cosmiconfig('inso'); |
| 79 | // set or detect .insorc in workingDir or cwd https://github.com/cosmiconfig/cosmiconfig?tab=readme-ov-file#explorersearch |
| 80 | const results = configFile ? await explorer.load(configFile) : await explorer.search(workingDir || process.cwd()); |
| 81 | |
| 82 | if (results && !results?.isEmpty) { |
| 83 | logger.debug(`Found config file at ${results?.filepath}.`); |
| 84 | const scripts = results.config?.scripts || {}; |
| 85 | const filePath = results.filepath; |
| 86 | const options = ['workingDir', 'ci', 'verbose', 'printOptions'].reduce((acc, key) => { |
| 87 | const value = results.config?.options?.[key]; |
| 88 | if (value) { |
| 89 | return { ...acc, [key]: value }; |
| 90 | } |
| 91 | return acc; |
| 92 | }, {}); |
| 93 | |
| 94 | return { options, scripts, filePath }; |
| 95 | } |
| 96 | } catch (error) { |
| 97 | // Report fatal error when loading from explicitly defined config file |
| 98 | if (configFile) { |
| 99 | console.log(`Could not find config file at ${configFile}.`); |
| 100 | console.error(error); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | return {}; |
| 105 | }; |
| 106 | |
| 107 | const localAppDir = getAppDataDir(getDefaultProductName()); |
| 108 |
no test coverage detected