mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-22 07:53:34 +01:00
feat: bru.getEnvName()
This commit is contained in:
parent
4aeb5cf56d
commit
7fbd338fa6
@ -38,7 +38,9 @@ const safeParseJSON = (data) => {
|
||||
const getEnvVars = (environment = {}) => {
|
||||
const variables = environment.variables;
|
||||
if (!variables || !variables.length) {
|
||||
return {};
|
||||
return {
|
||||
__name__: environment.name
|
||||
};
|
||||
}
|
||||
|
||||
const envVars = {};
|
||||
@ -48,7 +50,10 @@ const getEnvVars = (environment = {}) => {
|
||||
}
|
||||
});
|
||||
|
||||
return envVars;
|
||||
return {
|
||||
...envVars,
|
||||
__name__: environment.name
|
||||
}
|
||||
};
|
||||
|
||||
const getSize = (data) => {
|
||||
|
@ -1,8 +1,12 @@
|
||||
|
||||
class Bru {
|
||||
constructor(envVariables, collectionVariables) {
|
||||
this._envVariables = envVariables;
|
||||
this._collectionVariables = collectionVariables;
|
||||
this.envVariables = envVariables;
|
||||
this.collectionVariables = collectionVariables;
|
||||
}
|
||||
|
||||
getEnvName() {
|
||||
return this.envVariables.__name__;
|
||||
}
|
||||
|
||||
getProcessEnv(key) {
|
||||
@ -10,7 +14,7 @@ class Bru {
|
||||
}
|
||||
|
||||
getEnvVar(key) {
|
||||
return this._envVariables[key];
|
||||
return this.envVariables[key];
|
||||
}
|
||||
|
||||
setEnvVar(key, value) {
|
||||
@ -19,11 +23,11 @@ class Bru {
|
||||
}
|
||||
|
||||
// gracefully ignore if key is not present in environment
|
||||
if(!this._envVariables.hasOwnProperty(key)) {
|
||||
if(!this.envVariables.hasOwnProperty(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._envVariables[key] = value;
|
||||
this.envVariables[key] = value;
|
||||
}
|
||||
|
||||
setVar(key, value) {
|
||||
@ -31,11 +35,11 @@ class Bru {
|
||||
throw new Error('Key is required');
|
||||
}
|
||||
|
||||
this._collectionVariables[key] = value;
|
||||
this.collectionVariables[key] = value;
|
||||
}
|
||||
|
||||
getVar(key) {
|
||||
return this._collectionVariables[key];
|
||||
return this.collectionVariables[key];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user