Merge pull request #626 from embark-framework/bug_fix/duplicate-deps
fix duplicate dependencies and warn correctly for length
This commit is contained in:
commit
c0d2acd0d4
|
@ -178,7 +178,7 @@ class ContractDeployer {
|
|||
deployedAddress = deployedAddress.substr(2);
|
||||
}
|
||||
let linkReference = '__' + filename + ":" + contractObj.className;
|
||||
if (contractCode.indexOf(linkReference) < 0) {
|
||||
if (contractCode.indexOf(linkReference.substr(0, 38)) < 0) { // substr to simulate the cut that solc does
|
||||
continue;
|
||||
}
|
||||
if (linkReference.length > 40) {
|
||||
|
|
|
@ -215,7 +215,7 @@ class ContractsManager {
|
|||
contract = self.contracts[className];
|
||||
|
||||
// look in code for dependencies
|
||||
let libMatches = (contract.code.match(/\:(.*?)(?=_)/g) || []);
|
||||
let libMatches = (contract.code.match(/:(.*?)(?=_)/g) || []);
|
||||
for (let match of libMatches) {
|
||||
self.contractDependencies[className] = self.contractDependencies[className] || [];
|
||||
self.contractDependencies[className].push(match.substr(1));
|
||||
|
@ -251,14 +251,24 @@ class ContractsManager {
|
|||
}
|
||||
|
||||
// look in onDeploy for dependencies
|
||||
if (contract.onDeploy === [] || contract.onDeploy === undefined) continue;
|
||||
let regex = /\$\w+/g;
|
||||
contract.onDeploy.map((cmd) => {
|
||||
cmd.replace(regex, (match) => {
|
||||
self.contractDependencies[className] = self.contractDependencies[className] || [];
|
||||
self.contractDependencies[className].push(match.substr(1));
|
||||
if (contract.onDeploy !== [] && contract.onDeploy !== undefined) {
|
||||
let regex = /\$\w+/g;
|
||||
contract.onDeploy.map((cmd) => {
|
||||
cmd.replace(regex, (match) => {
|
||||
self.contractDependencies[className] = self.contractDependencies[className] || [];
|
||||
self.contractDependencies[className].push(match.substr(1));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Remove duplicates
|
||||
if (self.contractDependencies[className]) {
|
||||
const o = {};
|
||||
self.contractDependencies[className].forEach(function (e) {
|
||||
o[e] = true;
|
||||
});
|
||||
self.contractDependencies[className] = Object.keys(o);
|
||||
}
|
||||
}
|
||||
callback();
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue