@creditkarma/dynamic-config
Version:
Dynamic Config for Node.js backed by Consul and Vault
40 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.packageResolver = void 0;
const path = require("path");
const errors_1 = require("../errors");
const utils_1 = require("../utils");
function packageResolver() {
return {
type: 'remote',
name: 'package',
async init(configInstance, remoteOptions = {}) {
return {};
},
async get(key, type) {
const pkg = require(path.resolve(process.cwd(), 'package.json'));
if (pkg !== undefined) {
const value = pkg[key];
if (value !== undefined) {
if (type !== undefined) {
return utils_1.ConfigUtils.readValueForType(key, value, type);
}
else {
return value;
}
}
else {
throw new errors_1.MissingPackageProperty(key);
}
}
else {
throw new errors_1.MissingPackageProperty(key);
}
},
watch(key, cb, type) {
// Nothing to do. Can't watch environment variables.
},
};
}
exports.packageResolver = packageResolver;
//# sourceMappingURL=package.js.map