From be5526ed6c8a11dae4610d6aaef50c32e646e7d6 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 1 Jun 2018 11:44:59 -0400 Subject: [PATCH] fix: bail when registry ping fails close #1427 --- packages/@vue/cli/lib/util/shouldUseTaobao.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/@vue/cli/lib/util/shouldUseTaobao.js b/packages/@vue/cli/lib/util/shouldUseTaobao.js index 9caea641b5..fdac8855f6 100644 --- a/packages/@vue/cli/lib/util/shouldUseTaobao.js +++ b/packages/@vue/cli/lib/util/shouldUseTaobao.js @@ -36,14 +36,21 @@ module.exports = async function shouldUseTaobao () { const userCurrent = (await execa(`npm`, ['config', 'get', 'registry'])).stdout const defaultRegistry = registries.npm + if (removeSlash(userCurrent) !== removeSlash(defaultRegistry)) { // user has configured custom regsitry, respect that return save(false) } - const faster = await Promise.race([ - ping(defaultRegistry), - ping(registries.taobao) - ]) + + let faster + try { + faster = await Promise.race([ + ping(defaultRegistry), + ping(registries.taobao) + ]) + } catch (e) { + return save(false) + } if (faster !== registries.taobao) { // default is already faster