support getting contract from module; fix bug in which entire contract path was being replaced instead of just the beginning (if matching contracts in embark.json)

This commit is contained in:
Iuri Matias 2018-04-12 18:50:47 -04:00
parent e0ab9cbde4
commit 7dd36a7a3b
3 changed files with 11 additions and 2 deletions

View File

@ -146,8 +146,13 @@ Config.prototype.loadExternalContractsFiles = function() {
let contracts = this.contractsConfig.contracts;
for (let contractName in contracts) {
let contract = contracts[contractName];
if (contract.file) {
if (!contract.file) {
continue;
}
if (fs.existsSync(contract.file)) {
this.contractsFiles.push(new File({filename: contract.file, type: "dapp_file", basedir: '', path: contract.file}));
} else if (fs.existsSync(path.join('./node_modules/', contract.file))) {
this.contractsFiles.push(new File({filename: path.join('./node_modules/', contract.file), type: "dapp_file", basedir: '', path: path.join('./node_modules/', contract.file)}));
}
}
};

View File

@ -22,7 +22,8 @@ class Solidity {
let filename = file.filename;
for (let directory of self.contractDirectories) {
filename = filename.replace(directory, '');
let match = new RegExp("^" + directory);
filename = filename.replace(match, '');
}
file.content(function(fileContent) {

View File

@ -63,6 +63,9 @@
100
]
},
"ERC20": {
"file": "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"
},
"SimpleStorageTest": {
"file": "./some_folder/test_contract.sol",
"args": [