mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-20 02:58:05 +00:00
fix duplicate dependencies and warn correctly for length
This commit is contained in:
parent
5d8f236df3
commit
6908cf5cdc
@ -184,6 +184,9 @@ class ContractDeployer {
|
|||||||
if (linkReference.length > 40) {
|
if (linkReference.length > 40) {
|
||||||
return next(new Error(__("{{linkReference}} is too long, try reducing the path of the contract ({{filename}}) and/or its name {{contractName}}", {linkReference: linkReference, filename: filename, contractName: contractObj.className})));
|
return next(new Error(__("{{linkReference}} is too long, try reducing the path of the contract ({{filename}}) and/or its name {{contractName}}", {linkReference: linkReference, filename: filename, contractName: contractObj.className})));
|
||||||
}
|
}
|
||||||
|
if (contractCode.indexOf(linkReference) < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let toReplace = linkReference + "_".repeat(40 - linkReference.length);
|
let toReplace = linkReference + "_".repeat(40 - linkReference.length);
|
||||||
if (deployedAddress === undefined) {
|
if (deployedAddress === undefined) {
|
||||||
let libraryName = contractObj.className;
|
let libraryName = contractObj.className;
|
||||||
|
@ -212,7 +212,7 @@ class ContractsManager {
|
|||||||
contract = self.contracts[className];
|
contract = self.contracts[className];
|
||||||
|
|
||||||
// look in code for dependencies
|
// look in code for dependencies
|
||||||
let libMatches = (contract.code.match(/\:(.*?)(?=_)/g) || []);
|
let libMatches = (contract.code.match(/:(.*?)(?=_)/g) || []);
|
||||||
for (let match of libMatches) {
|
for (let match of libMatches) {
|
||||||
self.contractDependencies[className] = self.contractDependencies[className] || [];
|
self.contractDependencies[className] = self.contractDependencies[className] || [];
|
||||||
self.contractDependencies[className].push(match.substr(1));
|
self.contractDependencies[className].push(match.substr(1));
|
||||||
@ -248,7 +248,7 @@ class ContractsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// look in onDeploy for dependencies
|
// look in onDeploy for dependencies
|
||||||
if (contract.onDeploy === [] || contract.onDeploy === undefined) continue;
|
if (contract.onDeploy !== [] && contract.onDeploy !== undefined) {
|
||||||
let regex = /\$\w+/g;
|
let regex = /\$\w+/g;
|
||||||
contract.onDeploy.map((cmd) => {
|
contract.onDeploy.map((cmd) => {
|
||||||
cmd.replace(regex, (match) => {
|
cmd.replace(regex, (match) => {
|
||||||
@ -257,6 +257,16 @@ class ContractsManager {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove duplicates
|
||||||
|
if (self.contractDependencies[className]) {
|
||||||
|
const o = {};
|
||||||
|
self.contractDependencies[className].forEach(function (e) {
|
||||||
|
o[e] = true;
|
||||||
|
});
|
||||||
|
self.contractDependencies[className] = Object.keys(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
function setDependencyCount(callback) {
|
function setDependencyCount(callback) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user