git-release-manager
Version:
A tool to generate release notes from git commit history
66 lines • 3.1 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.readConfig = readConfig;
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
const configLoader_1 = require("./configLoader");
const constants_1 = require("./constants");
async function readConfig(customConfigPath = null, environment = null) {
const envSuffix = environment ? `.${environment}` : '';
// Handle custom config path
let finalCustomConfigPath = customConfigPath ? path.resolve(customConfigPath.replace(/\.json$/, `${envSuffix}.json`)) : null;
let customConfig = {};
if (finalCustomConfigPath && fs.existsSync(finalCustomConfigPath)) {
customConfig = await (0, configLoader_1.loadConfigFile)(finalCustomConfigPath);
}
let localConfig = {};
if (Object.keys(customConfig).length === 0) {
// Only load local config if custom config is empty
let finalLocalConfigPath = constants_1.LOCAL_CONFIG_PATH.replace(/\.json$/, `${envSuffix}.json`);
localConfig = fs.existsSync(finalLocalConfigPath) ? await (0, configLoader_1.loadConfigFile)(finalLocalConfigPath) : {};
}
// Handle default config path
let defaultConfigPath = constants_1.DEFAULT_CONFIG_PATH.replace(/\.json$/, `${envSuffix}.json`);
let defaultConfig = fs.existsSync(defaultConfigPath) ? await (0, configLoader_1.loadConfigFile)(defaultConfigPath) : await (0, configLoader_1.loadConfigFile)(constants_1.DEFAULT_CONFIG_PATH);
// Merge configurations with condition: default < (local if custom is empty) < custom
const result = {
...defaultConfig,
...localConfig,
...customConfig,
};
return result;
}
//# sourceMappingURL=configManager.js.map