@@ -29,7 +29,7 @@ const ping = url => new Promise((resolve, reject) => {
29
29
30
30
let checked
31
31
let result
32
- const shouldUseTaobao = async ( command ) => {
32
+ const shouldUseTaobao = async ( ) => {
33
33
// ensure this only gets called once.
34
34
if ( checked ) return result
35
35
checked = true
@@ -46,8 +46,8 @@ const shouldUseTaobao = async (command) => {
46
46
return val
47
47
}
48
48
49
- const userCurrent = ( await execa ( command , [ 'config' , 'get' , 'registry' ] ) ) . stdout
50
- const defaultRegistry = registries [ command ]
49
+ const userCurrent = ( await execa ( `npm` , [ 'config' , 'get' , 'registry' ] ) ) . stdout
50
+ const defaultRegistry = registries . npm
51
51
if ( userCurrent !== defaultRegistry ) {
52
52
// user has configured custom regsitry, respect that
53
53
return save ( false )
@@ -67,7 +67,7 @@ const shouldUseTaobao = async (command) => {
67
67
name : 'useTaobaoRegistry' ,
68
68
type : 'confirm' ,
69
69
message : chalk . yellow (
70
- ` Your connection to the the default ${ command } registry seems to be slow.\n` +
70
+ ` Your connection to the the default npm registry seems to be slow.\n` +
71
71
` Use ${ chalk . cyan ( registries . taobao ) } for faster installation?`
72
72
)
73
73
} ] )
@@ -102,20 +102,27 @@ module.exports = async function installDeps (targetDir, command, cliRegistry) {
102
102
} else if ( command === 'yarn' ) {
103
103
// do nothing
104
104
} else {
105
- throw new Error ( `unknown package manager: ${ command } ` )
105
+ throw new Error ( `Unknown package manager: ${ command } ` )
106
+ }
107
+
108
+ if ( command === 'yarn' && cliRegistry ) {
109
+ throw new Error (
110
+ `Inline registry is not supported when using yarn. ` +
111
+ `Please run \`yarn config set registry ${ cliRegistry } \` before running @vue/cli.`
112
+ )
106
113
}
107
114
108
115
const altRegistry = (
109
116
cliRegistry || (
110
- ( await shouldUseTaobao ( command ) )
117
+ ( command === 'npm' && await shouldUseTaobao ( ) )
111
118
? registries . taobao
112
119
: null
113
120
)
114
121
)
115
122
116
123
if ( altRegistry ) {
117
124
args . push ( `--registry=${ altRegistry } ` )
118
- if ( command === 'npm' && altRegistry === registries . taobao ) {
125
+ if ( altRegistry === registries . taobao ) {
119
126
args . push ( `--disturl=${ taobaoDistURL } ` )
120
127
}
121
128
}
0 commit comments