mirror of
https://github.com/usebruno/bruno.git
synced 2025-04-01 11:06:04 +02:00
feat: bru hasEnvVar, hasVar, deleteVar (#2531)
Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
parent
2aa7d26a89
commit
c8f95a34e9
@ -58,10 +58,13 @@ if (!SERVER_RENDERED) {
|
|||||||
'bru.cwd()',
|
'bru.cwd()',
|
||||||
'bru.getEnvName(key)',
|
'bru.getEnvName(key)',
|
||||||
'bru.getProcessEnv(key)',
|
'bru.getProcessEnv(key)',
|
||||||
|
'bru.hasEnvVar(key)',
|
||||||
'bru.getEnvVar(key)',
|
'bru.getEnvVar(key)',
|
||||||
'bru.setEnvVar(key,value)',
|
'bru.setEnvVar(key,value)',
|
||||||
|
'bru.hasVar(key)',
|
||||||
'bru.getVar(key)',
|
'bru.getVar(key)',
|
||||||
'bru.setVar(key,value)',
|
'bru.setVar(key,value)',
|
||||||
|
'bru.deleteVar(key)',
|
||||||
'bru.setNextRequest(requestName)'
|
'bru.setNextRequest(requestName)'
|
||||||
];
|
];
|
||||||
CodeMirror.registerHelper('hint', 'brunoJS', (editor, options) => {
|
CodeMirror.registerHelper('hint', 'brunoJS', (editor, options) => {
|
||||||
|
@ -43,6 +43,10 @@ class Bru {
|
|||||||
return this.processEnvVars[key];
|
return this.processEnvVars[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasEnvVar(key) {
|
||||||
|
return Object.hasOwn(this.envVariables, key);
|
||||||
|
}
|
||||||
|
|
||||||
getEnvVar(key) {
|
getEnvVar(key) {
|
||||||
return this._interpolate(this.envVariables[key]);
|
return this._interpolate(this.envVariables[key]);
|
||||||
}
|
}
|
||||||
@ -55,6 +59,10 @@ class Bru {
|
|||||||
this.envVariables[key] = value;
|
this.envVariables[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasVar(key) {
|
||||||
|
return Object.hasOwn(this.collectionVariables, key);
|
||||||
|
}
|
||||||
|
|
||||||
setVar(key, value) {
|
setVar(key, value) {
|
||||||
if (!key) {
|
if (!key) {
|
||||||
throw new Error('Creating a variable without specifying a name is not allowed.');
|
throw new Error('Creating a variable without specifying a name is not allowed.');
|
||||||
@ -81,6 +89,10 @@ class Bru {
|
|||||||
return this._interpolate(this.collectionVariables[key]);
|
return this._interpolate(this.collectionVariables[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteVar(key) {
|
||||||
|
delete this.collectionVariables[key];
|
||||||
|
}
|
||||||
|
|
||||||
getRequestVar(key) {
|
getRequestVar(key) {
|
||||||
return this._interpolate(this.requestVariables[key]);
|
return this._interpolate(this.requestVariables[key]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user