Metzploreur/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigData.js
clement callaert 244d45ceb8 Version 2
2023-11-01 17:33:25 +01:00

17 lines
645 B
JavaScript

import { IniSectionType } from "@smithy/types";
import { CONFIG_PREFIX_SEPARATOR } from "./loadSharedConfigFiles";
export const getConfigData = (data) => Object.entries(data)
.filter(([key]) => {
const sections = key.split(CONFIG_PREFIX_SEPARATOR);
if (sections.length === 2 && Object.values(IniSectionType).includes(sections[0])) {
return true;
}
return false;
})
.reduce((acc, [key, value]) => {
const updatedKey = key.startsWith(IniSectionType.PROFILE) ? key.split(CONFIG_PREFIX_SEPARATOR)[1] : key;
acc[updatedKey] = value;
return acc;
}, {
...(data.default && { default: data.default }),
});