feat: request execution mode (#3200)

This commit is contained in:
lohit 2024-09-26 15:54:20 +05:30 committed by GitHub
parent 2dd5ae400c
commit 25f43f12c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 0 deletions

View File

@ -55,6 +55,7 @@ if (!SERVER_RENDERED) {
'req.setMaxRedirects(maxRedirects)',
'req.getTimeout()',
'req.setTimeout(timeout)',
'req.getExecutionMode()',
'bru',
'bru.cwd()',
'bru.getEnvName(key)',

View File

@ -43,6 +43,8 @@ const runSingleRequest = async function (
request = prepareRequest(bruJson.request, collectionRoot);
request.__bruno__executionMode = 'cli';
const scriptingConfig = get(brunoConfig, 'scripts', {});
scriptingConfig.runtime = runtime;

View File

@ -525,6 +525,7 @@ const registerNetworkIpc = (mainWindow) => {
const collectionRoot = get(collection, 'root', {});
const request = prepareRequest(item, collection);
request.__bruno__executionMode = 'standalone';
const envVars = getEnvVars(environment);
const processEnvVars = getProcessEnvVars(collectionUid);
const brunoConfig = getBrunoConfig(collectionUid);
@ -717,6 +718,7 @@ const registerNetworkIpc = (mainWindow) => {
const collectionRoot = get(collection, 'root', {});
const _request = collectionRoot?.request;
const request = prepareCollectionRequest(_request, collectionRoot, collectionPath);
request.__bruno__executionMode = 'standalone';
const envVars = getEnvVars(environment);
const processEnvVars = getProcessEnvVars(collectionUid);
const brunoConfig = getBrunoConfig(collectionUid);
@ -960,6 +962,8 @@ const registerNetworkIpc = (mainWindow) => {
});
const request = prepareRequest(item, collection);
request.__bruno__executionMode = 'runner';
const requestUid = uuid();
const processEnvVars = getProcessEnvVars(collectionUid);

View File

@ -173,6 +173,10 @@ class BrunoRequest {
disableParsingResponseJson() {
this.req.__brunoDisableParsingResponseJson = true;
}
getExecutionMode() {
return this.req.__bruno__executionMode;
}
}
module.exports = BrunoRequest;

View File

@ -111,6 +111,12 @@ const addBrunoRequestShimToContext = (vm, req) => {
vm.setProp(reqObject, 'disableParsingResponseJson', disableParsingResponseJson);
disableParsingResponseJson.dispose();
let getExecutionMode = vm.newFunction('getExecutionMode', function () {
return marshallToVm(req.getExecutionMode(), vm);
});
vm.setProp(reqObject, 'getExecutionMode', getExecutionMode);
getExecutionMode.dispose();
vm.setProp(vm.global, 'req', reqObject);
reqObject.dispose();
};