mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-05 13:39:13 +01:00
fix(#295): bru.setEnvVar() should dynamically create a env var if not found
This commit is contained in:
parent
bacb70ea7e
commit
33f780fb76
@ -217,6 +217,19 @@ export const collectionsSlice = createSlice({
|
|||||||
|
|
||||||
if (variable) {
|
if (variable) {
|
||||||
variable.value = value;
|
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()
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -48,11 +48,6 @@ class Bru {
|
|||||||
throw new Error('Creating a env variable without specifying a name is not allowed.');
|
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;
|
this.envVariables[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user