From 260dd04e33f3f7d076446e3a7e0e6edf27b36b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Sat, 31 Aug 2019 12:28:50 +0200 Subject: [PATCH 1/2] Update shouldUseTaobao.js --- packages/@vue/cli/lib/util/shouldUseTaobao.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/@vue/cli/lib/util/shouldUseTaobao.js b/packages/@vue/cli/lib/util/shouldUseTaobao.js index 8384ad00d6..e1285c6d1f 100644 --- a/packages/@vue/cli/lib/util/shouldUseTaobao.js +++ b/packages/@vue/cli/lib/util/shouldUseTaobao.js @@ -38,9 +38,19 @@ module.exports = async function shouldUseTaobao (command) { return val } - const userCurrent = (await execa(command, ['config', 'get', 'registry'])).stdout - const defaultRegistry = registries[command] + let userCurrent + try { + userCurrent = (await execa(command, ['config', 'get', 'registry'])).stdout + } catch (error) { + try { + // Yarn 2 uses `npmRegistryServer` instead of `registry` + userCurrent = (await execa(command, ['config', 'get', 'npmRegistryServer'])).stdout + } catch (error) { + return save(false) + } + } + const defaultRegistry = registries[command] if (removeSlash(userCurrent) !== removeSlash(defaultRegistry)) { // user has configured custom registry, respect that return save(false) From 946bd88ff359a8d3705ec34fdf555960bab2137b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Sat, 31 Aug 2019 15:41:59 +0200 Subject: [PATCH 2/2] Fixes linting --- packages/@vue/cli/lib/util/shouldUseTaobao.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@vue/cli/lib/util/shouldUseTaobao.js b/packages/@vue/cli/lib/util/shouldUseTaobao.js index e1285c6d1f..011c362baf 100644 --- a/packages/@vue/cli/lib/util/shouldUseTaobao.js +++ b/packages/@vue/cli/lib/util/shouldUseTaobao.js @@ -41,11 +41,11 @@ module.exports = async function shouldUseTaobao (command) { let userCurrent try { userCurrent = (await execa(command, ['config', 'get', 'registry'])).stdout - } catch (error) { + } catch (registryError) { try { // Yarn 2 uses `npmRegistryServer` instead of `registry` userCurrent = (await execa(command, ['config', 'get', 'npmRegistryServer'])).stdout - } catch (error) { + } catch (npmRegistryServerError) { return save(false) } }