fix(#295): bru.setEnvVar() should dynamically create a env var if not found

This commit is contained in:
Anoop M D 2023-12-02 01:45:55 +05:30
parent bacb70ea7e
commit 33f780fb76
2 changed files with 13 additions and 5 deletions

View File

@ -217,6 +217,19 @@ export const collectionsSlice = createSlice({
if (variable) {
variable.value = value;
} else {
// __name__ is a private variable used to store the name of the environment
// this is not a user defined variable and hence should not be updated
if (key !== '__name__') {
activeEnvironment.variables.push({
name: key,
value,
secret: false,
enabled: true,
type: 'text',
uid: uuid()
});
}
}
});
}

View File

@ -48,11 +48,6 @@ class Bru {
throw new Error('Creating a env variable without specifying a name is not allowed.');
}
// gracefully ignore if key is not present in environment
if (!this.envVariables.hasOwnProperty(key)) {
return;
}
this.envVariables[key] = value;
}