Skip to content

Commit

Permalink
Work around Oh My Zsh auto-update
Browse files Browse the repository at this point in the history
Fixes #19
  • Loading branch information
sindresorhus committed Jan 17, 2021
1 parent 9f51d27 commit 77f574e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Expand Up @@ -8,6 +8,11 @@ const args = [
'echo -n "_SHELL_ENV_DELIMITER_"; env; echo -n "_SHELL_ENV_DELIMITER_"; exit'
];

const env = {
// Disables Oh My Zsh auto-update thing that can block the process.
DISABLE_AUTO_UPDATE: 'true'
};

const parseEnv = env => {
env = env.split('_SHELL_ENV_DELIMITER_')[1];
const ret = {};
Expand All @@ -26,7 +31,7 @@ module.exports = async shell => {
}

try {
const {stdout} = await execa(shell || defaultShell, args);
const {stdout} = await execa(shell || defaultShell, args, {env});
return parseEnv(stdout);
} catch (error) {
if (shell) {
Expand All @@ -43,7 +48,7 @@ module.exports.sync = shell => {
}

try {
const {stdout} = execa.sync(shell || defaultShell, args);
const {stdout} = execa.sync(shell || defaultShell, args, {env});
return parseEnv(stdout);
} catch (error) {
if (shell) {
Expand Down

0 comments on commit 77f574e

Please sign in to comment.