fix contract directories config

This commit is contained in:
Iuri Matias 2017-12-15 17:14:00 -05:00
parent 68886d7095
commit 1666be1158
4 changed files with 16 additions and 2 deletions

View File

@ -7,6 +7,7 @@ class Compiler {
this.plugins = options.plugins; this.plugins = options.plugins;
this.logger = options.logger; this.logger = options.logger;
this.solcVersion = options.solcVersion; this.solcVersion = options.solcVersion;
this.contractDirectories = options.contractDirectories;
} }
compile_contracts(contractFiles, cb) { compile_contracts(contractFiles, cb) {
@ -56,7 +57,12 @@ class Compiler {
function prepareInput(callback) { function prepareInput(callback) {
async.each(contractFiles, async.each(contractFiles,
function(file, fileCb) { function(file, fileCb) {
let filename = file.filename.replace('app/contracts/', ''); let filename = file.filename;
for (let directory of self.contractDirectories) {
filename = filename.replace(directory, '');
}
file.content(function(fileContent) { file.content(function(fileContent) {
input[filename] = fileContent; input[filename] = fileContent;
fileCb(); fileCb();

View File

@ -8,6 +8,7 @@ let Compiler = require('./compiler.js');
class ContractsManager { class ContractsManager {
constructor(options) { constructor(options) {
this.contractFiles = options.contractFiles; this.contractFiles = options.contractFiles;
this.contractDirectories = options.contractDirectories;
this.contractsConfig = options.contractsConfig; this.contractsConfig = options.contractsConfig;
this.contracts = {}; this.contracts = {};
this.logger = options.logger; this.logger = options.logger;
@ -25,7 +26,7 @@ class ContractsManager {
let self = this; let self = this;
async.waterfall([ async.waterfall([
function compileContracts(callback) { function compileContracts(callback) {
let compiler = new Compiler({plugins: self.plugins, logger: self.logger, solcVersion: self.solcVersion}); let compiler = new Compiler({plugins: self.plugins, logger: self.logger, solcVersion: self.solcVersion, contractDirectories: self.contractDirectories});
compiler.compile_contracts(self.contractFiles, function (err, compiledObject) { compiler.compile_contracts(self.contractFiles, function (err, compiledObject) {
self.compiledContracts = compiledObject; self.compiledContracts = compiledObject;
callback(err); callback(err);

View File

@ -26,6 +26,7 @@ class DeployManager {
function buildContracts(callback) { function buildContracts(callback) {
let contractsManager = new ContractsManager({ let contractsManager = new ContractsManager({
contractFiles: self.config.contractsFiles, contractFiles: self.config.contractsFiles,
contractDirectories: self.config.contractDirectories,
contractsConfig: self.config.contractsConfig, contractsConfig: self.config.contractsConfig,
logger: self.logger, logger: self.logger,
plugins: self.plugins plugins: self.plugins

View File

@ -198,6 +198,12 @@ Config.prototype.loadWebServerConfigFile = function() {
Config.prototype.loadEmbarkConfigFile = function() { Config.prototype.loadEmbarkConfigFile = function() {
var contracts = this.embarkConfig.contracts; var contracts = this.embarkConfig.contracts;
this.contractsFiles = this.loadFiles(contracts); this.contractsFiles = this.loadFiles(contracts);
// determine contract 'root' directories
this.contractDirectories = contracts.map((dir) => {
return dir.split("**")[0];
}).map((dir) => {
return dir.split("*.")[0];
});
this.buildDir = this.embarkConfig.buildDir; this.buildDir = this.embarkConfig.buildDir;
this.configDir = this.embarkConfig.config; this.configDir = this.embarkConfig.config;