mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-24 17:03:47 +01:00
feat: bru fns update (#3231)
This commit is contained in:
parent
96e58f2f40
commit
6bc8acd1e1
@ -69,6 +69,7 @@ if (!SERVER_RENDERED) {
|
||||
'bru.getVar(key)',
|
||||
'bru.setVar(key,value)',
|
||||
'bru.deleteVar(key)',
|
||||
'bru.deleteAllVars()',
|
||||
'bru.setNextRequest(requestName)',
|
||||
'req.disableParsingResponseJson()',
|
||||
'bru.getRequestVar(key)',
|
||||
|
@ -97,6 +97,14 @@ class Bru {
|
||||
delete this.runtimeVariables[key];
|
||||
}
|
||||
|
||||
deleteAllVars() {
|
||||
for (let key in this.runtimeVariables) {
|
||||
if (this.runtimeVariables.hasOwnProperty(key)) {
|
||||
delete this.runtimeVariables[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getCollectionVar(key) {
|
||||
return this._interpolate(this.collectionVariables[key]);
|
||||
}
|
||||
|
@ -21,6 +21,12 @@ const addBruShimToContext = (vm, bru) => {
|
||||
vm.setProp(bruObject, 'getProcessEnv', getProcessEnv);
|
||||
getProcessEnv.dispose();
|
||||
|
||||
let hasEnvVar = vm.newFunction('hasEnvVar', function (key) {
|
||||
return marshallToVm(bru.hasEnvVar(vm.dump(key)), vm);
|
||||
});
|
||||
vm.setProp(bruObject, 'hasEnvVar', hasEnvVar);
|
||||
hasEnvVar.dispose();
|
||||
|
||||
let getEnvVar = vm.newFunction('getEnvVar', function (key) {
|
||||
return marshallToVm(bru.getEnvVar(vm.dump(key)), vm);
|
||||
});
|
||||
@ -33,6 +39,12 @@ const addBruShimToContext = (vm, bru) => {
|
||||
vm.setProp(bruObject, 'setEnvVar', setEnvVar);
|
||||
setEnvVar.dispose();
|
||||
|
||||
let hasVar = vm.newFunction('hasVar', function (key) {
|
||||
return marshallToVm(bru.hasVar(vm.dump(key)), vm);
|
||||
});
|
||||
vm.setProp(bruObject, 'hasVar', hasVar);
|
||||
hasVar.dispose();
|
||||
|
||||
let getVar = vm.newFunction('getVar', function (key) {
|
||||
return marshallToVm(bru.getVar(vm.dump(key)), vm);
|
||||
});
|
||||
@ -45,6 +57,18 @@ const addBruShimToContext = (vm, bru) => {
|
||||
vm.setProp(bruObject, 'setVar', setVar);
|
||||
setVar.dispose();
|
||||
|
||||
let deleteVar = vm.newFunction('deleteVar', function (key) {
|
||||
bru.deleteVar(vm.dump(key));
|
||||
});
|
||||
vm.setProp(bruObject, 'deleteVar', deleteVar);
|
||||
deleteVar.dispose();
|
||||
|
||||
let deleteAllVars = vm.newFunction('deleteAllVars', function () {
|
||||
bru.deleteAllVars();
|
||||
});
|
||||
vm.setProp(bruObject, 'deleteAllVars', deleteAllVars);
|
||||
deleteAllVars.dispose();
|
||||
|
||||
let setNextRequest = vm.newFunction('setNextRequest', function (nextRequest) {
|
||||
bru.setNextRequest(vm.dump(nextRequest));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user