From ede0bd8ca6d7cb16621501007ccb957701bfd308 Mon Sep 17 00:00:00 2001 From: Matt Harris Date: Tue, 3 Oct 2017 16:58:00 +0100 Subject: [PATCH] Fix #448 - Add offline build detection and advice (#452) --- src/cli.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index 1e6af7f..f3c6218 100755 --- a/src/cli.js +++ b/src/cli.js @@ -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);