Add directory list to list of allowed paths

This commit is contained in:
Richard Ramos 2018-07-24 11:56:35 -04:00
parent 3f69a5c2e4
commit 21d65e8f8c

View File

@ -3,8 +3,10 @@ const shelljs = require('shelljs');
const fs = require('fs');
const path = require('path');
function compileSolcContract(logger, filename, callback) {
shelljs.exec(`solc --optimize --combined-json abi,bin,bin-runtime,compact-format,hashes,interface,metadata ${filename}`,
function compileSolcContract(logger, filename, allowedDirectories, callback) {
const command = `solc --optimize --combined-json abi,bin,bin-runtime,compact-format,hashes,interface,metadata --allow-paths ${allowedDirectories.join(',')} ${filename}`;
console.log(command);
shelljs.exec(command,
{silent: true}, (code, stdout, stderr) => {
if (stderr) {
@ -40,11 +42,13 @@ function compileSolc(embark, contractFiles, cb) {
}
logger.info("compiling solidity contracts with command line solc...");
const allowedDirectories = contractFiles.map((contractFile) => path.dirname(path.join(process.cwd(), contractFile.path)));
let compiled_object = {};
async.each(contractFiles,
function (file, fileCb) {
compileSolcContract(logger, file.filename, (err, compileString) => {
compileSolcContract(logger, file.filename, allowedDirectories, (err, compileString) => {
if (err) {
return fileCb(err);
}