From 088f1d6b478112ce4f44bf1be7e76e573da9d2bd Mon Sep 17 00:00:00 2001 From: Daniel Maurer Date: Fri, 21 Jul 2023 14:59:57 +0200 Subject: [PATCH] feat: missing files from last commit --- .../components/environments/my/Details.vue | 2 +- .../components/environments/teams/Details.vue | 2 +- .../hoppscotch-js-sandbox/src/preRequest.ts | 40 ++++++++++--------- .../hoppscotch-js-sandbox/src/test-runner.ts | 40 ++++++++++--------- 4 files changed, 46 insertions(+), 38 deletions(-) diff --git a/packages/hoppscotch-common/src/components/environments/my/Details.vue b/packages/hoppscotch-common/src/components/environments/my/Details.vue index 900567650..06e31345c 100644 --- a/packages/hoppscotch-common/src/components/environments/my/Details.vue +++ b/packages/hoppscotch-common/src/components/environments/my/Details.vue @@ -120,7 +120,7 @@ import IconTrash2 from "~icons/lucide/trash-2" import IconDone from "~icons/lucide/check" import IconPlus from "~icons/lucide/plus" import IconTrash from "~icons/lucide/trash" -import IconLock from "~icons/lucide/lock" +import IconLock from "~icons/lucide/lock" import { clone } from "lodash-es" import { computed, ref, watch } from "vue" import * as E from "fp-ts/Either" diff --git a/packages/hoppscotch-common/src/components/environments/teams/Details.vue b/packages/hoppscotch-common/src/components/environments/teams/Details.vue index 2064db0eb..40b5cebc1 100644 --- a/packages/hoppscotch-common/src/components/environments/teams/Details.vue +++ b/packages/hoppscotch-common/src/components/environments/teams/Details.vue @@ -149,7 +149,7 @@ import IconTrash from "~icons/lucide/trash" import IconTrash2 from "~icons/lucide/trash-2" import IconDone from "~icons/lucide/check" import IconPlus from "~icons/lucide/plus" -import IconLock from "~icons/lucide/lock" +import IconLock from "~icons/lucide/lock" import { platform } from "~/platform" type EnvironmentVariable = { diff --git a/packages/hoppscotch-js-sandbox/src/preRequest.ts b/packages/hoppscotch-js-sandbox/src/preRequest.ts index 3c61576bf..c82eba811 100644 --- a/packages/hoppscotch-js-sandbox/src/preRequest.ts +++ b/packages/hoppscotch-js-sandbox/src/preRequest.ts @@ -87,28 +87,32 @@ export const execPreRequestScript = ( } }) - const envSetHandle = vm.newFunction("set", (keyHandle, valueHandle) => { - const key: unknown = vm.dump(keyHandle) - const value: unknown = vm.dump(valueHandle) + const envSetHandle = vm.newFunction( + "set", + (keyHandle, valueHandle, secretHandle) => { + const key: unknown = vm.dump(keyHandle) + const value: unknown = vm.dump(valueHandle) + const secret: boolean = vm.dump(secretHandle) + + if (typeof key !== "string") { + return { + error: vm.newString("Expected key to be a string"), + } + } + + if (typeof value !== "string") { + return { + error: vm.newString("Expected value to be a string"), + } + } + + currentEnvs = setEnv(key, value, secret, currentEnvs) - if (typeof key !== "string") { return { - error: vm.newString("Expected key to be a string"), + value: vm.undefined, } } - - if (typeof value !== "string") { - return { - error: vm.newString("Expected value to be a string"), - } - } - - currentEnvs = setEnv(key, value, currentEnvs) - - return { - value: vm.undefined, - } - }) + ) const envResolveHandle = vm.newFunction("resolve", (valueHandle) => { const value: unknown = vm.dump(valueHandle) diff --git a/packages/hoppscotch-js-sandbox/src/test-runner.ts b/packages/hoppscotch-js-sandbox/src/test-runner.ts index 720e1fa9d..5e2176d62 100644 --- a/packages/hoppscotch-js-sandbox/src/test-runner.ts +++ b/packages/hoppscotch-js-sandbox/src/test-runner.ts @@ -527,28 +527,32 @@ export const execTestScript = ( } ) - const envSetHandle = vm.newFunction("set", (keyHandle, valueHandle) => { - const key: unknown = vm.dump(keyHandle) - const value: unknown = vm.dump(valueHandle) + const envSetHandle = vm.newFunction( + "set", + (keyHandle, valueHandle, secretHandle) => { + const key: unknown = vm.dump(keyHandle) + const value: unknown = vm.dump(valueHandle) + const secret: boolean = vm.dump(secretHandle) + + if (typeof key !== "string") { + return { + error: vm.newString("Expected key to be a string"), + } + } + + if (typeof value !== "string") { + return { + error: vm.newString("Expected value to be a string"), + } + } + + currentEnvs = setEnv(key, value, secret, currentEnvs) - if (typeof key !== "string") { return { - error: vm.newString("Expected key to be a string"), + value: vm.undefined, } } - - if (typeof value !== "string") { - return { - error: vm.newString("Expected value to be a string"), - } - } - - currentEnvs = setEnv(key, value, currentEnvs) - - return { - value: vm.undefined, - } - }) + ) const envResolveHandle = vm.newFunction("resolve", (valueHandle) => { const value: unknown = vm.dump(valueHandle)