|
1 | 1 | import type { |
2 | 2 | AindexConfig, |
| 3 | + CleanupProtectionOptions, |
3 | 4 | ConfigLoaderOptions, |
4 | 5 | ConfigLoadResult, |
5 | 6 | ILogger, |
@@ -151,12 +152,17 @@ export class ConfigLoader { |
151 | 152 | return reversed.reduce<UserConfigFile>((acc, config) => { |
152 | 153 | const mergedAindex = this.mergeAindex(acc.aindex, config.aindex) |
153 | 154 | const mergedOutputScopes = this.mergeOutputScopeOptions(acc.outputScopes, config.outputScopes) |
| 155 | + const mergedCleanupProtection = this.mergeCleanupProtectionOptions( |
| 156 | + acc.cleanupProtection, |
| 157 | + config.cleanupProtection |
| 158 | + ) |
154 | 159 |
|
155 | 160 | return { |
156 | 161 | ...acc, |
157 | 162 | ...config, |
158 | 163 | ...mergedAindex != null ? {aindex: mergedAindex} : {}, |
159 | | - ...mergedOutputScopes != null ? {outputScopes: mergedOutputScopes} : {} |
| 164 | + ...mergedOutputScopes != null ? {outputScopes: mergedOutputScopes} : {}, |
| 165 | + ...mergedCleanupProtection != null ? {cleanupProtection: mergedCleanupProtection} : {} |
160 | 166 | } |
161 | 167 | }, {}) |
162 | 168 | } |
@@ -213,6 +219,22 @@ export class ConfigLoader { |
213 | 219 | return {plugins: mergedPlugins} |
214 | 220 | } |
215 | 221 |
|
| 222 | + private mergeCleanupProtectionOptions( |
| 223 | + a?: CleanupProtectionOptions, |
| 224 | + b?: CleanupProtectionOptions |
| 225 | + ): CleanupProtectionOptions | undefined { |
| 226 | + if (a == null && b == null) return void 0 |
| 227 | + if (a == null) return b |
| 228 | + if (b == null) return a |
| 229 | + |
| 230 | + return { |
| 231 | + rules: [ |
| 232 | + ...a.rules ?? [], |
| 233 | + ...b.rules ?? [] |
| 234 | + ] |
| 235 | + } |
| 236 | + } |
| 237 | + |
216 | 238 | private resolveTilde(p: string): string { |
217 | 239 | if (p.startsWith('~')) return path.join(os.homedir(), p.slice(1)) |
218 | 240 | return p |
|
0 commit comments