From af37a495c2bf3fe378bc46eda9a426a825f31848 Mon Sep 17 00:00:00 2001 From: Its-Treason <39559178+Its-treason@users.noreply.github.com> Date: Wed, 20 Nov 2024 21:41:25 +0100 Subject: [PATCH] fix: Code generation variable replacement --- packages/bruno-core/src/codeGenerator/index.ts | 7 +++++-- packages/bruno-electron/src/ipc/collection.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/bruno-core/src/codeGenerator/index.ts b/packages/bruno-core/src/codeGenerator/index.ts index 66b41269d1..658d7cbb31 100644 --- a/packages/bruno-core/src/codeGenerator/index.ts +++ b/packages/bruno-core/src/codeGenerator/index.ts @@ -61,8 +61,11 @@ export async function generateCode( variables: { process: { process: { - // @ts-ignore - env: process.env + // @ts-expect-error `process.env` is a dict with weird typings + env: { + ...process.env, + ...collection.processEnvVariables + } } }, environment: environmentVariableRecord, diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index d9ba5b1ef5..dd4cf7fae7 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -34,6 +34,7 @@ const { getPreferences } = require('../store/preferences'); const { getRequestFromCurlCommand } = require('../utils/curl'); const Watcher = require('../app/watcher'); const LastOpenedCollection = require('../store/last-opened-collections'); +const { handleAuthorizationCodeInElectron } = require('../utils/handleAuthorizationCodeInElectron'); const environmentSecretsStore = new EnvironmentSecretsStore(); @@ -754,7 +755,16 @@ ipcMain.handle('renderer:delete-cookies-for-domain', async (event, domain) => { }); ipcMain.handle('renderer:generate-code', async (event, item, collection, environment, globalVariables, options) => { - return await generateCode(item, collection, getPreferences(), cookieJar, options, environment, globalVariables); + return await generateCode( + item, + collection, + getPreferences(), + cookieJar, + options, + handleAuthorizationCodeInElectron, + environment, + globalVariables + ); }); ipcMain.handle('renderer:curl-to-request', async (event, curlString) => {