This repository has been archived on 2024-09-11. You can view files and clone it, but cannot push or open issues or pull requests.
svrjs-blog-newsletter/cronjob/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js
2024-05-26 22:54:55 +02:00

27 lines
969 B
JavaScript

import { getConfigData } from "./getConfigData";
import { getConfigFilepath } from "./getConfigFilepath";
import { getCredentialsFilepath } from "./getCredentialsFilepath";
import { parseIni } from "./parseIni";
import { slurpFile } from "./slurpFile";
const swallowError = () => ({});
export const CONFIG_PREFIX_SEPARATOR = ".";
export const loadSharedConfigFiles = async (init = {}) => {
const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
const parsedFiles = await Promise.all([
slurpFile(configFilepath, {
ignoreCache: init.ignoreCache,
})
.then(parseIni)
.then(getConfigData)
.catch(swallowError),
slurpFile(filepath, {
ignoreCache: init.ignoreCache,
})
.then(parseIni)
.catch(swallowError),
]);
return {
configFile: parsedFiles[0],
credentialsFile: parsedFiles[1],
};
};