From 97abcb05f1ed3e6a3ff14d1064206ee0c07edbf8 Mon Sep 17 00:00:00 2001 From: erezrokah Date: Wed, 16 Jun 2021 18:27:39 +0200 Subject: [PATCH] fix(windows): retry getGlobalConfig --- src/utils/get-global-config.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/utils/get-global-config.js b/src/utils/get-global-config.js index d1521e6a787..da61f4ce243 100644 --- a/src/utils/get-global-config.js +++ b/src/utils/get-global-config.js @@ -12,7 +12,7 @@ const globalConfigDefaults = { cliId: uuidv4(), } -const getGlobalConfig = async function () { +const getGlobalConfigOnce = async function () { const configPath = getPathInHome(['config.json']) // Legacy config file in home ~/.netlify/config.json const legacyPath = getLegacyPathInHome(['config.json']) @@ -28,5 +28,19 @@ const getGlobalConfig = async function () { return configStore } +const getGlobalConfig = async function () { + const retries = 3 + for (let retry = 1; retry <= retries; retry++) { + try { + // eslint-disable-next-line no-await-in-loop + return await getGlobalConfigOnce() + } catch (error) { + if (retry === retries) { + throw error + } + } + } +} + // Memoise config result so that we only load it once module.exports = memoizeOne(getGlobalConfig)