MCPcopy Create free account
hub / github.com/react/create-react-app / checkIfOnline

Function checkIfOnline

packages/create-react-app/createReactApp.js:1054–1075  ·  view source on GitHub ↗
(useYarn)

Source from the content-addressed store, hash-verified

1052}
1053
1054function checkIfOnline(useYarn) {
1055 if (!useYarn) {
1056 // Don't ping the Yarn registry.
1057 // We'll just assume the best case.
1058 return Promise.resolve(true);
1059 }
1060
1061 return new Promise(resolve => {
1062 dns.lookup('registry.yarnpkg.com', err => {
1063 let proxy;
1064 if (err != null && (proxy = getProxy())) {
1065 // If a proxy is defined, we likely can't resolve external hostnames.
1066 // Try to resolve the proxy name as an indication of a connection.
1067 dns.lookup(url.parse(proxy).hostname, proxyErr => {
1068 resolve(proxyErr == null);
1069 });
1070 } else {
1071 resolve(err == null);
1072 }
1073 });
1074 });
1075}
1076
1077function executeNodeScript({ cwd, args }, data, source) {
1078 return new Promise((resolve, reject) => {

Callers 1

runFunction · 0.85

Calls 2

getProxyFunction · 0.85
resolveFunction · 0.50

Tested by

no test coverage detected