UNPKG

brek

Version:
30 lines 851 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadConfFile = void 0; const node_fs_1 = require("node:fs"); const node_path_1 = require("node:path"); const errors_1 = require("./errors"); const _1 = require("."); /** * Loads a configuration file relative to the BREK_CONFIG_DIR. Does not * require leading slashes. * @param parts */ function loadConfFile(parts) { const file = (0, node_path_1.resolve)(_1.BREK_CONFIG_DIR, ...parts); let fileContent; try { fileContent = (0, node_fs_1.readFileSync)(file, 'utf-8'); } catch (e) { return {}; } try { return JSON.parse(fileContent); } catch (e) { throw new errors_1.InvalidConf([`${file} is not valid JSON`]); } } exports.loadConfFile = loadConfFile; //# sourceMappingURL=loadConfFile.js.map