Skip to content

Commit be5526e

Browse files
committedJun 1, 2018
fix: bail when registry ping fails
close #1427
1 parent 68f273a commit be5526e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed
 

‎packages/@vue/cli/lib/util/shouldUseTaobao.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,21 @@ module.exports = async function shouldUseTaobao () {
3636

3737
const userCurrent = (await execa(`npm`, ['config', 'get', 'registry'])).stdout
3838
const defaultRegistry = registries.npm
39+
3940
if (removeSlash(userCurrent) !== removeSlash(defaultRegistry)) {
4041
// user has configured custom regsitry, respect that
4142
return save(false)
4243
}
43-
const faster = await Promise.race([
44-
ping(defaultRegistry),
45-
ping(registries.taobao)
46-
])
44+
45+
let faster
46+
try {
47+
faster = await Promise.race([
48+
ping(defaultRegistry),
49+
ping(registries.taobao)
50+
])
51+
} catch (e) {
52+
return save(false)
53+
}
4754

4855
if (faster !== registries.taobao) {
4956
// default is already faster

0 commit comments

Comments
 (0)
Please sign in to comment.