Fix #448 - Add offline build detection and advice (#452)

This commit is contained in:
Matt Harris 2017-10-03 16:58:00 +01:00 committed by Ronan Jouchet
parent 84dcde9d5b
commit ede0bd8ca6
1 changed files with 11 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import 'source-map-support/register';
import program from 'commander';
import nativefier from './index';
const dns = require('dns');
const packageJson = require('./../package');
function collect(val, memo) {
@ -23,6 +24,15 @@ function getProcessEnvs(val) {
return pEnv;
}
function checkInternet() {
dns.lookup('npmjs.com', (err) => {
if (err && err.code === 'ENOTFOUND') {
console.log('\nNo Internet Connection\nTo offline build, download electron from https://github.com/electron/electron/releases\nand place in ~/AppData/Local/electron/Cache/ on Windows,\n~/.cache/electron on Linux or ~/Library/Caches/electron/ on Mac\nUse --electron-version to specify the version you downloaded.');
}
});
}
if (require.main === module) {
program
.version(packageJson.version)
@ -77,7 +87,7 @@ if (require.main === module) {
if (!process.argv.slice(2).length) {
program.help();
}
checkInternet();
nativefier(program, (error, appPath) => {
if (error) {
console.error(error);