| 783 | } |
| 784 | |
| 785 | function loadConfigFile(configPath: string): ConfigLoadResult { |
| 786 | let fileContent = "" |
| 787 | try { |
| 788 | fileContent = readFileSync(configPath, "utf-8") |
| 789 | } catch { |
| 790 | return { data: null } |
| 791 | } |
| 792 | |
| 793 | try { |
| 794 | const parsed = parse(fileContent, undefined, { allowTrailingComma: true }) |
| 795 | if (parsed === undefined || parsed === null) { |
| 796 | return { data: null, parseError: "Config file is empty or invalid" } |
| 797 | } |
| 798 | return { data: parsed } |
| 799 | } catch (error: any) { |
| 800 | return { data: null, parseError: error.message || "Failed to parse config" } |
| 801 | } |
| 802 | } |
| 803 | |
| 804 | function mergeStrategies( |
| 805 | base: PluginConfig["strategies"], |