mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-02 17:03:36 +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..");
|
self.logger.info("loading solc compiler..");
|
||||||
solcW.load_compiler(function () {
|
solcW.load_compiler(function (err) {
|
||||||
callback();
|
callback(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function compileContracts(callback) {
|
function compileContracts(callback) {
|
||||||
|
@ -29,7 +29,10 @@ class SolcW {
|
|||||||
solcProcess.send({action: 'loadCompiler', solcLocation: 'solc'});
|
solcProcess.send({action: 'loadCompiler', solcLocation: 'solc'});
|
||||||
} else {
|
} else {
|
||||||
let npm = new Npm({logger: this.logger});
|
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);
|
let requirePath = path.join(process.env.PWD, location);
|
||||||
solcProcess.send({action: 'loadCompiler', solcLocation: requirePath});
|
solcProcess.send({action: 'loadCompiler', solcLocation: requirePath});
|
||||||
});
|
});
|
||||||
|
@ -24,9 +24,9 @@ class Npm {
|
|||||||
if (fs.existsSync(packageDirectory + "/" + packageName + ".js")) {
|
if (fs.existsSync(packageDirectory + "/" + packageName + ".js")) {
|
||||||
if (returnContent) {
|
if (returnContent) {
|
||||||
let distFile = packageDirectory + packageName + ".js";
|
let distFile = packageDirectory + packageName + ".js";
|
||||||
callback(fs.readFileSync(distFile).toString());
|
callback(null, fs.readFileSync(distFile).toString());
|
||||||
} else {
|
} else {
|
||||||
callback(packageDirectory);
|
callback(null, packageDirectory);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fs.mkdirpSync(packageDirectory);
|
fs.mkdirpSync(packageDirectory);
|
||||||
@ -36,9 +36,9 @@ class Npm {
|
|||||||
utils.extractTar(packageDirectory + "/" + packageName + ".js", packageDirectory, function() {
|
utils.extractTar(packageDirectory + "/" + packageName + ".js", packageDirectory, function() {
|
||||||
if (returnContent) {
|
if (returnContent) {
|
||||||
let distFile = packageDirectory + packageName + ".js";
|
let distFile = packageDirectory + packageName + ".js";
|
||||||
callback(fs.readFileSync(distFile).toString());
|
callback(null, fs.readFileSync(distFile).toString());
|
||||||
} else {
|
} else {
|
||||||
callback(packageDirectory);
|
callback(null, packageDirectory);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -52,9 +52,9 @@ class Npm {
|
|||||||
if (fs.existsSync(packageDirectory + "/downloaded_package.tgz")) {
|
if (fs.existsSync(packageDirectory + "/downloaded_package.tgz")) {
|
||||||
if (returnContent) {
|
if (returnContent) {
|
||||||
let distFile = packageDirectory + returnContent;
|
let distFile = packageDirectory + returnContent;
|
||||||
callback(fs.readFileSync(distFile).toString());
|
callback(null, fs.readFileSync(distFile).toString());
|
||||||
} else {
|
} else {
|
||||||
callback(packageDirectory);
|
callback(null, packageDirectory);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fs.mkdirpSync(packageDirectory);
|
fs.mkdirpSync(packageDirectory);
|
||||||
@ -64,9 +64,9 @@ class Npm {
|
|||||||
utils.extractTar(packageDirectory + "/downloaded_package.tgz", packageDirectory, function() {
|
utils.extractTar(packageDirectory + "/downloaded_package.tgz", packageDirectory, function() {
|
||||||
if (returnContent) {
|
if (returnContent) {
|
||||||
let distFile = packageDirectory + returnContent;
|
let distFile = packageDirectory + returnContent;
|
||||||
callback(fs.readFileSync(distFile).toString());
|
callback(null, fs.readFileSync(distFile).toString());
|
||||||
} else {
|
} else {
|
||||||
callback(packageDirectory);
|
callback(null, packageDirectory);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -78,7 +78,13 @@ class Npm {
|
|||||||
let self = this;
|
let self = this;
|
||||||
let npmRegistry = "https://registry.npmjs.org/" + packageName + "/" + version;
|
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);
|
let registryJSON = JSON.parse(body);
|
||||||
|
|
||||||
if (getFromGit) {
|
if (getFromGit) {
|
||||||
|
@ -42,9 +42,8 @@ function httpGetRequest(httpObj, url, callback) {
|
|||||||
res.on('end', function () {
|
res.on('end', function () {
|
||||||
callback(null, body);
|
callback(null, body);
|
||||||
});
|
});
|
||||||
res.on('error', function (err) {
|
}).on('error', function (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user