Skip to content

Commit 90af8c2

Browse files
authored
Don't ping the Yarn registry if user doesn't have Yarn
1 parent 9b60cc1 commit 90af8c2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

packages/create-react-app/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ function shouldUseYarn() {
155155
}
156156
}
157157

158-
function install(dependencies, verbose, isOnline) {
158+
function install(useYarn, dependencies, verbose, isOnline) {
159159
return new Promise(function(resolve, reject) {
160160
var command;
161161
var args;
162-
if (shouldUseYarn()) {
162+
if (useYarn) {
163163
command = 'yarnpkg';
164164
args = [
165165
'add',
@@ -201,10 +201,11 @@ function run(root, appName, version, verbose, originalDirectory, template) {
201201
', and ' + chalk.cyan(packageName) + '...'
202202
);
203203
console.log();
204-
205-
checkIfOnline()
204+
205+
var useYarn = shouldUseYarn();
206+
checkIfOnline(useYarn)
206207
.then(function(isOnline) {
207-
return install(allDependencies, verbose, isOnline);
208+
return install(useYarn, allDependencies, verbose, isOnline);
208209
})
209210
.then(function() {
210211
checkNodeVersion(packageName);
@@ -422,7 +423,13 @@ function isSafeToCreateProjectIn(root) {
422423
});
423424
}
424425

425-
function checkIfOnline() {
426+
function checkIfOnline(useYarn) {
427+
if (!useYarn) {
428+
// Don't ping the Yarn registry.
429+
// We'll just assume the best case.
430+
return Promise.resolve(true);
431+
}
432+
426433
return new Promise(function(resolve) {
427434
dns.resolve('registry.yarnpkg.com', function(err) {
428435
resolve(err === null);

0 commit comments

Comments
 (0)