(ctx: PluginInput)
| 967 | } |
| 968 | |
| 969 | export function getConfig(ctx: PluginInput): PluginConfig { |
| 970 | let config = deepCloneConfig(defaultConfig) |
| 971 | const configPaths = getConfigPaths(ctx) |
| 972 | |
| 973 | if (!configPaths.global) { |
| 974 | createDefaultConfig() |
| 975 | } |
| 976 | |
| 977 | const layers: Array<{ path: string | null; name: string; isProject: boolean }> = [ |
| 978 | { path: configPaths.global, name: "config", isProject: false }, |
| 979 | { path: configPaths.configDir, name: "configDir config", isProject: true }, |
| 980 | { path: configPaths.project, name: "project config", isProject: true }, |
| 981 | ] |
| 982 | |
| 983 | for (const layer of layers) { |
| 984 | if (!layer.path) { |
| 985 | continue |
| 986 | } |
| 987 | |
| 988 | const result = loadConfigFile(layer.path) |
| 989 | if (result.parseError) { |
| 990 | scheduleParseWarning( |
| 991 | ctx, |
| 992 | `DCP: Invalid ${layer.name}`, |
| 993 | `${layer.path}\n${result.parseError}\nUsing previous/default values`, |
| 994 | ) |
| 995 | continue |
| 996 | } |
| 997 | |
| 998 | if (!result.data) { |
| 999 | continue |
| 1000 | } |
| 1001 | |
| 1002 | showConfigWarnings(ctx, layer.path, result.data, layer.isProject) |
| 1003 | config = mergeLayer(config, result.data) |
| 1004 | } |
| 1005 | |
| 1006 | return config |
| 1007 | } |
no test coverage detected