MCPcopy Create free account
hub / github.com/Create-Node-App/create-node-app / checkIfOnline

Function checkIfOnline

src/helpers.js:110–131  ·  view source on GitHub ↗
(useYarn)

Source from the content-addressed store, hash-verified

108}
109
110function checkIfOnline(useYarn) {
111 if (!useYarn) {
112 // Don't ping the Yarn registry.
113 // We'll just assume the best case.
114 return Promise.resolve(true);
115 }
116
117 return new Promise((resolve) => {
118 dns.lookup('registry.yarnpkg.com', (err) => {
119 let proxy;
120 if (err != null && (proxy = getProxy())) {
121 // If a proxy is defined, we likely can't resolve external hostnames.
122 // Try to resolve the proxy name as an indication of a connection.
123 dns.lookup(url.parse(proxy).hostname, (proxyErr) => {
124 resolve(proxyErr == null);
125 });
126 } else {
127 resolve(err == null);
128 }
129 });
130 });
131}
132
133module.exports = {
134 toCamelCase,

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected