BREAKING CHANGE(core): update
This commit is contained in:
parent
56ce78f794
commit
205d27f9a0
12
test/test.ts
12
test/test.ts
@ -18,18 +18,18 @@ tap.test('should create a new class', async () => {
|
||||
});
|
||||
|
||||
tap.test('key1 should be not be overwritten since it is already present', async () => {
|
||||
expect(testQenv.getEnvVarOnDemand('key1')).toEqual('original');
|
||||
expect(testQenv.getEnvVarOnDemand('key1')).toEqual('original');
|
||||
expect(await testQenv.getEnvVarOnDemand('key1')).toEqual('original');
|
||||
expect(await testQenv.getEnvVarOnDemand('key1')).toEqual('original');
|
||||
});
|
||||
|
||||
tap.test('key2 should be read from Yml', async () => {
|
||||
expect(testQenv.getEnvVarOnDemand('key2')).toEqual('fromJson');
|
||||
expect(testQenv.getEnvVarOnDemand('key2')).toEqual('fromJson');
|
||||
expect(await testQenv.getEnvVarOnDemand('key2')).toEqual('fromJson');
|
||||
expect(await testQenv.getEnvVarOnDemand('key2')).toEqual('fromJson');
|
||||
});
|
||||
|
||||
tap.test('keyValueObjectArray should hold all retrieved values', async () => {
|
||||
expect(testQenv.keyValueObject.key1).toEqual('original');
|
||||
expect(testQenv.keyValueObject.key2).toEqual('fromJson');
|
||||
expect(await testQenv.keyValueObject.key1).toEqual('original');
|
||||
expect(await testQenv.keyValueObject.key2).toEqual('fromJson');
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/qenv',
|
||||
version: '5.0.5',
|
||||
version: '6.0.0',
|
||||
description: 'easy promised environments'
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ export class Qenv {
|
||||
}
|
||||
}
|
||||
|
||||
public getEnvVarOnDemand(envVarName: string): string | undefined {
|
||||
public async getEnvVarOnDemand(envVarName: string): Promise<string | undefined> {
|
||||
return (
|
||||
this.getFromEnvironmentVariable(envVarName) ||
|
||||
this.getFromEnvJsonFile(envVarName) ||
|
||||
@ -71,8 +71,18 @@ export class Qenv {
|
||||
);
|
||||
}
|
||||
|
||||
public getEnvVarOnDemandAsObject(envVarName: string): any {
|
||||
const rawValue = this.getEnvVarOnDemand(envVarName);
|
||||
public async getEnvVarOnDemandSync(envVarName: string): Promise<string | undefined> {
|
||||
console.warn('requesting env var sync leaves out potentially important async env sources.');
|
||||
return (
|
||||
this.getFromEnvironmentVariable(envVarName) ||
|
||||
this.getFromEnvJsonFile(envVarName) ||
|
||||
this.getFromDockerSecret(envVarName) ||
|
||||
this.getFromDockerSecretJson(envVarName)
|
||||
);
|
||||
}
|
||||
|
||||
public async getEnvVarOnDemandAsObject(envVarName: string): Promise<any> {
|
||||
const rawValue = await this.getEnvVarOnDemand(envVarName);
|
||||
if (rawValue && rawValue.startsWith('base64Object:')) {
|
||||
const base64Part = rawValue.split('base64Object:')[1];
|
||||
return this.decodeBase64(base64Part);
|
||||
|
Loading…
Reference in New Issue
Block a user