mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-24 14:01:29 +02:00
Merge pull request #587 from rayoz12/552-run-post-response-vars-and-scripts-on-error
Fixes: #552: Runs Post response vars and scripts on HTTP error.
This commit is contained in:
commit
5f77ee342b
@ -461,6 +461,56 @@ const registerNetworkIpc = (mainWindow) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// run post-response vars
|
||||||
|
const postResponseVars = get(request, 'vars.res', []);
|
||||||
|
if (postResponseVars && postResponseVars.length) {
|
||||||
|
const varsRuntime = new VarsRuntime();
|
||||||
|
const result = varsRuntime.runPostResponseVars(
|
||||||
|
postResponseVars,
|
||||||
|
request,
|
||||||
|
error.response,
|
||||||
|
envVars,
|
||||||
|
collectionVariables,
|
||||||
|
collectionPath,
|
||||||
|
processEnvVars
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
mainWindow.webContents.send('main:script-environment-update', {
|
||||||
|
envVariables: result.envVariables,
|
||||||
|
collectionVariables: result.collectionVariables,
|
||||||
|
requestUid,
|
||||||
|
collectionUid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// run post-response script
|
||||||
|
const responseScript = compact([get(collectionRoot, 'request.script.res'), get(request, 'script.res')]).join(
|
||||||
|
os.EOL
|
||||||
|
);
|
||||||
|
if (responseScript && responseScript.length) {
|
||||||
|
const scriptRuntime = new ScriptRuntime();
|
||||||
|
const result = await scriptRuntime.runResponseScript(
|
||||||
|
decomment(responseScript),
|
||||||
|
request,
|
||||||
|
error.response,
|
||||||
|
envVars,
|
||||||
|
collectionVariables,
|
||||||
|
collectionPath,
|
||||||
|
onConsoleLog,
|
||||||
|
processEnvVars,
|
||||||
|
scriptingConfig
|
||||||
|
);
|
||||||
|
|
||||||
|
mainWindow.webContents.send('main:script-environment-update', {
|
||||||
|
envVariables: result.envVariables,
|
||||||
|
collectionVariables: result.collectionVariables,
|
||||||
|
requestUid,
|
||||||
|
collectionUid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// run tests
|
// run tests
|
||||||
const testFile = compact([
|
const testFile = compact([
|
||||||
get(collectionRoot, 'request.tests'),
|
get(collectionRoot, 'request.tests'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user