| 1052 | } |
| 1053 | |
| 1054 | function 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 | |
| 1077 | function executeNodeScript({ cwd, args }, data, source) { |
| 1078 | return new Promise((resolve, reject) => { |