Inject globals env into pre-request scripts

This commit is contained in:
Andrew Bastin
2021-06-05 21:07:06 -04:00
parent d9aa965069
commit ddbc9ca61b
2 changed files with 22 additions and 1 deletions

View File

@@ -1,4 +1,7 @@
import { getCurrentEnvironment } from "~/newstore/environments"
import {
getCurrentEnvironment,
getGlobalEnvironment,
} from "~/newstore/environments"
export default function getEnvironmentVariablesFromScript(script: any) {
const _variables: Record<string, string> = {}
@@ -9,6 +12,14 @@ export default function getEnvironmentVariablesFromScript(script: any) {
_variables[variable.key] = variable.value
}
const globalEnv = getGlobalEnvironment()
if (globalEnv) {
for (const variable of globalEnv.variables) {
_variables[variable.key] = variable.value
}
}
try {
// the pw object is the proxy by which pre-request scripts can pass variables to the request.
// for security and control purposes, this is the only way a pre-request script should modify variables.