diff --git a/packages/bruno-app/src/components/CodeEditor/index.js b/packages/bruno-app/src/components/CodeEditor/index.js index 9ff58a16f..ddc38aff8 100644 --- a/packages/bruno-app/src/components/CodeEditor/index.js +++ b/packages/bruno-app/src/components/CodeEditor/index.js @@ -58,10 +58,13 @@ if (!SERVER_RENDERED) { 'bru.cwd()', 'bru.getEnvName(key)', 'bru.getProcessEnv(key)', + 'bru.hasEnvVar(key)', 'bru.getEnvVar(key)', 'bru.setEnvVar(key,value)', + 'bru.hasVar(key)', 'bru.getVar(key)', 'bru.setVar(key,value)', + 'bru.deleteVar(key)', 'bru.setNextRequest(requestName)' ]; CodeMirror.registerHelper('hint', 'brunoJS', (editor, options) => { diff --git a/packages/bruno-js/src/bru.js b/packages/bruno-js/src/bru.js index b3d363b9a..21629c9ac 100644 --- a/packages/bruno-js/src/bru.js +++ b/packages/bruno-js/src/bru.js @@ -43,6 +43,10 @@ class Bru { return this.processEnvVars[key]; } + hasEnvVar(key) { + return Object.hasOwn(this.envVariables, key); + } + getEnvVar(key) { return this._interpolate(this.envVariables[key]); } @@ -55,6 +59,10 @@ class Bru { this.envVariables[key] = value; } + hasVar(key) { + return Object.hasOwn(this.collectionVariables, key); + } + setVar(key, value) { if (!key) { 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]); } + deleteVar(key) { + delete this.collectionVariables[key]; + } + getRequestVar(key) { return this._interpolate(this.requestVariables[key]); }