Skip to content

Commit

Permalink
fix: bail when registry ping fails
Browse files Browse the repository at this point in the history
close #1427
  • Loading branch information
yyx990803 committed Jun 1, 2018
1 parent 68f273a commit be5526e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/@vue/cli/lib/util/shouldUseTaobao.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be5526e

Please sign in to comment.