import fs from "fs"; import grabDirNames from "../names/grab-dir-names"; import EJSON from "../../ejson"; import envsub from "../../envsub"; export default function grabConfig(params) { const { appConfigJSONFile, userConfigJSONFilePath } = grabDirNames({ userId: params === null || params === void 0 ? void 0 : params.userId, }); const appConfigJSON = envsub(fs.readFileSync(appConfigJSONFile, "utf-8")); const appConfig = EJSON.parse(appConfigJSON); if (!userConfigJSONFilePath) { return { appConfig, userConfig: null }; } if (!fs.existsSync(userConfigJSONFilePath)) { fs.writeFileSync(userConfigJSONFilePath, JSON.stringify({ main: {}, }), "utf-8"); } const userConfigJSON = envsub(fs.readFileSync(userConfigJSONFilePath, "utf-8")); const userConfig = (EJSON.parse(userConfigJSON) || { main: {}, }); return { appConfig, userConfig }; }