Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
31bf1b27a4 | |||
a77def5844 | |||
2357699f3e | |||
01f5784488 | |||
80f35c39aa | |||
87f55773bd |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/qenv",
|
"name": "@pushrocks/qenv",
|
||||||
"version": "3.0.4",
|
"version": "3.0.7",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/qenv",
|
"name": "@pushrocks/qenv",
|
||||||
"version": "3.0.4",
|
"version": "3.0.7",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "easy promised environments",
|
"description": "easy promised environments",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -17,10 +17,12 @@ tap.test('should create a new class', async () => {
|
|||||||
|
|
||||||
tap.test('key1 should be not be overwritten since it is already present', async () => {
|
tap.test('key1 should be not be overwritten since it is already present', async () => {
|
||||||
expect(process.env.key1).to.equal('original');
|
expect(process.env.key1).to.equal('original');
|
||||||
|
expect(qenvTestObject.getEnvVarOnDemand('key1')).to.equal('original');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('key2 should be read from Yml', async () => {
|
tap.test('key2 should be read from Yml', async () => {
|
||||||
expect(process.env.key2).to.equal('fromYml');
|
expect(process.env.key2).to.equal('fromYml');
|
||||||
|
expect(qenvTestObject.getEnvVarOnDemand('key2')).to.equal('fromYml');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('keyValueObjectArray should hold all retrieved values', async () => {
|
tap.test('keyValueObjectArray should hold all retrieved values', async () => {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import * as plugins from './qenv.plugins';
|
import * as plugins from './qenv.plugins';
|
||||||
|
plugins.smartlog.defaultLogger.enableConsole();
|
||||||
|
|
||||||
export interface IKeyValueObject {
|
export interface IKeyValueObject {
|
||||||
key: string;
|
key: string;
|
||||||
@ -74,7 +75,6 @@ export class Qenv {
|
|||||||
try {
|
try {
|
||||||
envYml = plugins.smartfile.fs.toObjectSync(this.envFilePathAbsolute);
|
envYml = plugins.smartfile.fs.toObjectSync(this.envFilePathAbsolute);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("env file couldn't be found at " + this.envFilePathAbsolute);
|
|
||||||
envYml = {};
|
envYml = {};
|
||||||
}
|
}
|
||||||
let envVar: string;
|
let envVar: string;
|
||||||
@ -129,12 +129,16 @@ export class Qenv {
|
|||||||
|
|
||||||
let chosenVar: string = null;
|
let chosenVar: string = null;
|
||||||
if (envVar) {
|
if (envVar) {
|
||||||
|
this.logger.log('ok', `found ${requiredEnvVar} as environment variable`);
|
||||||
chosenVar = envVar;
|
chosenVar = envVar;
|
||||||
} else if (envFileVar) {
|
} else if (envFileVar) {
|
||||||
|
this.logger.log('ok', `found ${requiredEnvVar} as env.yml variable`);
|
||||||
chosenVar = envFileVar;
|
chosenVar = envFileVar;
|
||||||
} else if (dockerSecret) {
|
} else if (dockerSecret) {
|
||||||
|
this.logger.log('ok', `found ${requiredEnvVar} as docker secret`);
|
||||||
chosenVar = dockerSecret;
|
chosenVar = dockerSecret;
|
||||||
} else if (dockerSecretJson) {
|
} else if (dockerSecretJson) {
|
||||||
|
this.logger.log('ok', `found ${requiredEnvVar} as docker secret.json`);
|
||||||
chosenVar = dockerSecretJson;
|
chosenVar = dockerSecretJson;
|
||||||
}
|
}
|
||||||
return chosenVar;
|
return chosenVar;
|
||||||
@ -185,5 +189,5 @@ export class Qenv {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return missingEnvVars;
|
return missingEnvVars;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user