42 lines
3.8 KiB
JavaScript
42 lines
3.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const plugins = require("./qenv.plugins");
|
|
exports.getRequiredEnvVars = (pathArg, requiredEnvVarsArray) => {
|
|
let qenvFilePath = plugins.path.join(pathArg, 'qenv.yml');
|
|
let qenvFile = plugins.smartfile.fs.toObjectSync(qenvFilePath);
|
|
for (let keyArg in qenvFile.vars) {
|
|
requiredEnvVarsArray.push(qenvFile.vars[keyArg]);
|
|
}
|
|
};
|
|
exports.getAvailableEnvVars = (requiredEnvVarsArg, envYmlPathArg, availableEnvVarsArray, keyValueObjectArrayArg) => {
|
|
envYmlPathArg = plugins.path.join(envYmlPathArg, 'env.yml');
|
|
let envYml;
|
|
try {
|
|
envYml = plugins.smartfile.fs.toObjectSync(envYmlPathArg);
|
|
}
|
|
catch (err) {
|
|
console.log("env file couldn't be found at " + envYmlPathArg);
|
|
envYml = {};
|
|
}
|
|
for (let requiredEnvVar of requiredEnvVarsArg) {
|
|
if (process.env[requiredEnvVar]) {
|
|
availableEnvVarsArray.push(requiredEnvVar);
|
|
keyValueObjectArrayArg.push({
|
|
key: requiredEnvVar,
|
|
value: process.env[requiredEnvVar]
|
|
});
|
|
}
|
|
else if (envYml.hasOwnProperty(requiredEnvVar)) {
|
|
process.env[requiredEnvVar] = envYml[requiredEnvVar];
|
|
availableEnvVarsArray.push(requiredEnvVar);
|
|
keyValueObjectArrayArg.push({
|
|
key: requiredEnvVar,
|
|
value: process.env[requiredEnvVar]
|
|
});
|
|
}
|
|
}
|
|
};
|
|
exports.getMissingEnvVars = (requiredEnvVarsArray, availableEnvVarsArray) => {
|
|
return plugins.lodash.difference(requiredEnvVarsArray, availableEnvVarsArray);
|
|
};
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicWVudi5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvcWV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