mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-22 15:04:47 +00:00
Update main.js
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user