Skip to content

Commit

Permalink
Adjust to check yarnpkg.com first, then check the proxy address only …
Browse files Browse the repository at this point in the history
…if that failed
  • Loading branch information
bsyk committed Aug 7, 2017
1 parent 235739e commit 99c4ab1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/create-react-app/createReactApp.js
Expand Up @@ -614,14 +614,16 @@ function checkIfOnline(useYarn) {
}

return new Promise(resolve => {
let host = 'registry.yarnpkg.com';
// If a proxy is defined, we likely can't resolve external hostnames.
// Try to resolve the proxy name as an indication of a connection.
if (process.env.https_proxy) {
host = url.parse(process.env.https_proxy).hostname;
}
dns.lookup(host, err => {
resolve(err === null);
dns.lookup('registry.yarnpkg.com', err => {
if (err != null && process.env.https_proxy) {
// If a proxy is defined, we likely can't resolve external hostnames.
// Try to resolve the proxy name as an indication of a connection.
dns.lookup(url.parse(process.env.https_proxy).hostname, proxyErr => {
resolve(proxyErr == null);
});
} else {
resolve(err == null);
}
});
});
}

0 comments on commit 99c4ab1

Please sign in to comment.