mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-23 12:11:16 +00:00
warn user if attempting to download package without internet connection
This commit is contained in:
parent
b764ecf4d6
commit
f90321a23e
@ -81,8 +81,8 @@ class Compiler {
|
||||
}
|
||||
|
||||
self.logger.info("loading solc compiler..");
|
||||
solcW.load_compiler(function () {
|
||||
callback();
|
||||
solcW.load_compiler(function (err) {
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
function compileContracts(callback) {
|
||||
|
@ -29,7 +29,10 @@ class SolcW {
|
||||
solcProcess.send({action: 'loadCompiler', solcLocation: 'solc'});
|
||||
} else {
|
||||
let npm = new Npm({logger: this.logger});
|
||||
npm.getPackageVersion('solc', this.solcVersion, false, false, function(location) {
|
||||
npm.getPackageVersion('solc', this.solcVersion, false, false, function(err, location) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
let requirePath = path.join(process.env.PWD, location);
|
||||
solcProcess.send({action: 'loadCompiler', solcLocation: requirePath});
|
||||
});
|
||||
|
@ -24,9 +24,9 @@ class Npm {
|
||||
if (fs.existsSync(packageDirectory + "/" + packageName + ".js")) {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + packageName + ".js";
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
callback(null, fs.readFileSync(distFile).toString());
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
callback(null, packageDirectory);
|
||||
}
|
||||
} else {
|
||||
fs.mkdirpSync(packageDirectory);
|
||||
@ -36,9 +36,9 @@ class Npm {
|
||||
utils.extractTar(packageDirectory + "/" + packageName + ".js", packageDirectory, function() {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + packageName + ".js";
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
callback(null, fs.readFileSync(distFile).toString());
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
callback(null, packageDirectory);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -52,9 +52,9 @@ class Npm {
|
||||
if (fs.existsSync(packageDirectory + "/downloaded_package.tgz")) {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + returnContent;
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
callback(null, fs.readFileSync(distFile).toString());
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
callback(null, packageDirectory);
|
||||
}
|
||||
} else {
|
||||
fs.mkdirpSync(packageDirectory);
|
||||
@ -64,9 +64,9 @@ class Npm {
|
||||
utils.extractTar(packageDirectory + "/downloaded_package.tgz", packageDirectory, function() {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + returnContent;
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
callback(null, fs.readFileSync(distFile).toString());
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
callback(null, packageDirectory);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -78,7 +78,13 @@ class Npm {
|
||||
let self = this;
|
||||
let npmRegistry = "https://registry.npmjs.org/" + packageName + "/" + version;
|
||||
|
||||
utils.httpsGet(npmRegistry, function (_err, body) {
|
||||
utils.httpsGet(npmRegistry, function (err, body) {
|
||||
if (err) {
|
||||
if (err.code === 'ENOTFOUND') {
|
||||
return callback("can't reach " + err.hostname + " to download " + packageName + " " + version + " - are you connected to the internet?");
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
let registryJSON = JSON.parse(body);
|
||||
|
||||
if (getFromGit) {
|
||||
|
@ -42,10 +42,9 @@ function httpGetRequest(httpObj, url, callback) {
|
||||
res.on('end', function () {
|
||||
callback(null, body);
|
||||
});
|
||||
res.on('error', function (err) {
|
||||
}).on('error', function (err) {
|
||||
callback(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function httpGet(url, callback) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user