pandora
Version:
A powerful and lightweight application manager for Node.js applications powered by TypeScript.
46 lines • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const pandora_core_sdk_1 = require("pandora-core-sdk");
const path_1 = require("path");
const pandora_dollar_1 = require("pandora-dollar");
class CoreSDKWithExtendedConfig extends pandora_core_sdk_1.CoreSDK {
constructor(options) {
if (!options.extendConfig) {
options.extendConfig = [];
}
options.extendConfig.push({
config: require('../pandoraConfig'),
configDir: path_1.dirname(require.resolve('../pandoraConfig'))
});
for (const item of CoreSDKWithExtendedConfig.parsePandoraConfigFromEnvVar()) {
options.extendConfig.push(item);
}
super(options);
}
static parsePandoraConfigFromEnvVar() {
const PANDORA_CONFIG = process.env.PANDORA_CONFIG;
const ret = [];
if (!PANDORA_CONFIG) {
return ret;
}
const paths = PANDORA_CONFIG.split(':');
for (const path of paths) {
if (!path.trim()) {
continue;
}
try {
ret.push({
config: require(path),
configDir: path_1.dirname(path)
});
}
catch (err) {
pandora_dollar_1.consoleLogger.warn('Load config error from', path);
pandora_dollar_1.consoleLogger.warn(err);
}
}
return ret;
}
}
exports.CoreSDKWithExtendedConfig = CoreSDKWithExtendedConfig;
//# sourceMappingURL=CoreSDKWithExtendedConfig.js.map