Skip to content

Commit 3aa513a

Browse files
arcanispksunkara
authored andcommitted
Add a variant for config get registry (#4530)
* Update shouldUseTaobao.js * Fixes linting
1 parent 5cce80c commit 3aa513a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,19 @@ module.exports = async function shouldUseTaobao (command) {
3838
return val
3939
}
4040

41-
const userCurrent = (await execa(command, ['config', 'get', 'registry'])).stdout
42-
const defaultRegistry = registries[command]
41+
let userCurrent
42+
try {
43+
userCurrent = (await execa(command, ['config', 'get', 'registry'])).stdout
44+
} catch (registryError) {
45+
try {
46+
// Yarn 2 uses `npmRegistryServer` instead of `registry`
47+
userCurrent = (await execa(command, ['config', 'get', 'npmRegistryServer'])).stdout
48+
} catch (npmRegistryServerError) {
49+
return save(false)
50+
}
51+
}
4352

53+
const defaultRegistry = registries[command]
4454
if (removeSlash(userCurrent) !== removeSlash(defaultRegistry)) {
4555
// user has configured custom registry, respect that
4656
return save(false)

0 commit comments

Comments
 (0)