From 5ebfa2b0bd7b133c1a27e568e11cb5f8fe9075c9 Mon Sep 17 00:00:00 2001 From: theolivenbaum Date: Tue, 26 Oct 2021 21:34:35 +0200 Subject: [PATCH 1/3] Update main.js --- ElectronNET.Host/main.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 8e98182..8a22df9 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -506,19 +506,6 @@ function shellEnvSync() { shell = process.env.SHELL ||'/bin/zsh'; } - const parseEnv = env => { - env = env.split('_SHELL_ENV_DELIMITER_')[1]; - const returnValue = {}; - - for (const line of stripAnsi(env).split('\n').filter(line => Boolean(line))) { - const [key, ...values] = line.split('='); - returnValue[key] = values.join('='); - } - - return returnValue; - }; - - try { const stdout = cProcess.execSync(shell, args, { env }) return parseEnv(stdout); @@ -531,6 +518,18 @@ function shellEnvSync() { } } +function parseEnv(envString) { + envString = envString.split('_SHELL_ENV_DELIMITER_')[1]; + const returnValue = {}; + + for (const line of stripAnsi(envString).split('\n').filter(line => Boolean(line))) { + const [key, ...values] = line.split('='); + returnValue[key] = values.join('='); + } + + return returnValue; +} + function stripAnsi(string) { if (typeof string !== 'string') { throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``); @@ -546,4 +545,4 @@ function ansiRegex({ onlyFirst = false } = {}) { ].join('|'); return new RegExp(pattern, onlyFirst ? undefined : 'g'); -} \ No newline at end of file +} From ae929738144bed10099f9eb99f889a1c6c8460ee Mon Sep 17 00:00:00 2001 From: theolivenbaum Date: Tue, 26 Oct 2021 22:58:54 +0200 Subject: [PATCH 2/3] Update main.js --- ElectronNET.Host/main.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 8a22df9..3acfa85 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -507,7 +507,7 @@ function shellEnvSync() { } try { - const stdout = cProcess.execSync(shell, args, { env }) + const { stdout } = cProcess.spawnSync(shell, args, { env }) return parseEnv(stdout); } catch (error) { if (shell) { @@ -519,14 +519,16 @@ function shellEnvSync() { } function parseEnv(envString) { - envString = envString.split('_SHELL_ENV_DELIMITER_')[1]; const returnValue = {}; - for (const line of stripAnsi(envString).split('\n').filter(line => Boolean(line))) { - const [key, ...values] = line.split('='); - returnValue[key] = values.join('='); + if(envString) { + envString = envString.split('_SHELL_ENV_DELIMITER_')[1]; + for (const line of stripAnsi(envString).split('\n').filter(line => Boolean(line))) { + const [key, ...values] = line.split('='); + returnValue[key] = values.join('='); + } } - + return returnValue; } From 2297669e6d7da8c9981f051e7ccda3291c08793b Mon Sep 17 00:00:00 2001 From: theolivenbaum Date: Wed, 27 Oct 2021 09:11:33 +0200 Subject: [PATCH 3/3] Update main.js --- ElectronNET.Host/main.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 3acfa85..c2b73e6 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -1,4 +1,4 @@ -const { app } = require('electron'); +const { app } = require('electron'); const { BrowserWindow } = require('electron'); const { protocol } = require('electron'); const path = require('path'); @@ -6,8 +6,9 @@ const cProcess = require('child_process'); const process = require('process'); const portscanner = require('portscanner'); const { imageSize } = require('image-size'); +const { connect } = require('http2'); -fixPath(); +fixPath(); //For macOS and Linux packaged-apps, the path variable might be missing let io, server, browserWindows, ipc, apiProcess, loadURL; let appApi, menu, dialogApi, notification, tray, webContents; @@ -507,7 +508,10 @@ function shellEnvSync() { } try { - const { stdout } = cProcess.spawnSync(shell, args, { env }) + let { stdout } = cProcess.spawnSync(shell, args, { env }); + if(Buffer.isBuffer(stdout)){ + stdout = stdout.toString(); + } return parseEnv(stdout); } catch (error) { if (shell) {