Detecting if solc is installed

This commit is contained in:
Richard Ramos 2018-05-30 15:52:42 -04:00
parent e2a076df12
commit 3da50e6104
1 changed files with 11 additions and 1 deletions

View File

@ -26,6 +26,14 @@ function compileSolc(logger, contractFiles, cb) {
if (!contractFiles || !contractFiles.length) {
return cb();
}
const solc = shelljs.which('solc');
if (!solc) {
logger.warn('solc is not installed on your machine');
logger.info('You can install it by following the instructions on: http://solidity.readthedocs.io/en/latest/installing-solidity.html');
process.exit();
}
logger.info("compiling solidity contracts with command line solc...");
let compiled_object = {};
async.each(contractFiles,
@ -35,7 +43,9 @@ function compileSolc(logger, contractFiles, cb) {
return fileCb(err);
}
let json = JSON.parse(compileString);
let jsonStart = compileString.indexOf("\"contracts\":{");
let json = JSON.parse(compileString.substr(jsonStart - 1));
for (let contractFile in json.contracts) {
let className = contractFile.substr( contractFile.indexOf(":") + 1);