www_ourworld_freezone/vendor/integration/utils/loadConfig.ts
sasha-astiadi 30a3c6a3d1 new
2024-07-01 17:20:18 +02:00

17 lines
435 B
TypeScript

import fs from 'node:fs';
import yaml from 'js-yaml';
const loadConfig = async (configPathOrData: string | object) => {
if (typeof configPathOrData === 'string') {
const content = fs.readFileSync(configPathOrData, 'utf8');
if (configPathOrData.endsWith('.yaml') || configPathOrData.endsWith('.yml')) {
return yaml.load(content);
}
return content;
}
return configPathOrData;
};
export default loadConfig;