From 5ebfa2b0bd7b133c1a27e568e11cb5f8fe9075c9 Mon Sep 17 00:00:00 2001 From: theolivenbaum Date: Tue, 26 Oct 2021 21:34:35 +0200 Subject: [PATCH] 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 +}