done
This commit is contained in:
parent
caf1c5fcaf
commit
20b7180a43
5 changed files with 207 additions and 158 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { readFileSync, existsSync } from 'fs';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { ConfigLoader } from '../types';
|
||||
import { ConfigLoaderError } from '../errors';
|
||||
import { ConfigLoader } from '../types';
|
||||
|
||||
export class FileLoader implements ConfigLoader {
|
||||
readonly priority = 50; // Medium priority
|
||||
|
|
@ -30,10 +30,7 @@ export class FileLoader implements ConfigLoader {
|
|||
// Merge configs (later configs override earlier ones)
|
||||
return this.deepMerge(...configs);
|
||||
} catch (error) {
|
||||
throw new ConfigLoaderError(
|
||||
`Failed to load configuration files: ${error}`,
|
||||
'FileLoader'
|
||||
);
|
||||
throw new ConfigLoaderError(`Failed to load configuration files: ${error}`, 'FileLoader');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +53,10 @@ export class FileLoader implements ConfigLoader {
|
|||
if (value === null || value === undefined) {
|
||||
result[key] = value;
|
||||
} else if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
|
||||
result[key] = this.deepMerge(result[key] as Record<string, unknown> || {}, value as Record<string, unknown>);
|
||||
result[key] = this.deepMerge(
|
||||
(result[key] as Record<string, unknown>) || {},
|
||||
value as Record<string, unknown>
|
||||
);
|
||||
} else {
|
||||
result[key] = value;
|
||||
}
|
||||
|
|
@ -65,4 +65,4 @@ export class FileLoader implements ConfigLoader {
|
|||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue