feat: bru.getEnvName()

This commit is contained in:
Anoop M D 2023-09-06 20:36:55 +05:30
parent 4aeb5cf56d
commit 7fbd338fa6
2 changed files with 18 additions and 9 deletions

View File

@ -38,7 +38,9 @@ const safeParseJSON = (data) => {
const getEnvVars = (environment = {}) => { const getEnvVars = (environment = {}) => {
const variables = environment.variables; const variables = environment.variables;
if (!variables || !variables.length) { if (!variables || !variables.length) {
return {}; return {
__name__: environment.name
};
} }
const envVars = {}; const envVars = {};
@ -48,7 +50,10 @@ const getEnvVars = (environment = {}) => {
} }
}); });
return envVars; return {
...envVars,
__name__: environment.name
}
}; };
const getSize = (data) => { const getSize = (data) => {

View File

@ -1,8 +1,12 @@
class Bru { class Bru {
constructor(envVariables, collectionVariables) { constructor(envVariables, collectionVariables) {
this._envVariables = envVariables; this.envVariables = envVariables;
this._collectionVariables = collectionVariables; this.collectionVariables = collectionVariables;
}
getEnvName() {
return this.envVariables.__name__;
} }
getProcessEnv(key) { getProcessEnv(key) {
@ -10,7 +14,7 @@ class Bru {
} }
getEnvVar(key) { getEnvVar(key) {
return this._envVariables[key]; return this.envVariables[key];
} }
setEnvVar(key, value) { setEnvVar(key, value) {
@ -19,11 +23,11 @@ class Bru {
} }
// gracefully ignore if key is not present in environment // gracefully ignore if key is not present in environment
if(!this._envVariables.hasOwnProperty(key)) { if(!this.envVariables.hasOwnProperty(key)) {
return; return;
} }
this._envVariables[key] = value; this.envVariables[key] = value;
} }
setVar(key, value) { setVar(key, value) {
@ -31,11 +35,11 @@ class Bru {
throw new Error('Key is required'); throw new Error('Key is required');
} }
this._collectionVariables[key] = value; this.collectionVariables[key] = value;
} }
getVar(key) { getVar(key) {
return this._collectionVariables[key]; return this.collectionVariables[key];
} }
} }