mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-17 08:07:51 +00:00
remove dependencyCount
This commit is contained in:
parent
324e09eb35
commit
d88d172c76
@ -41,9 +41,6 @@ class ContractsManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.events.setCommandHandler("contracts:reset:dependencies", (cb) => {
|
self.events.setCommandHandler("contracts:reset:dependencies", (cb) => {
|
||||||
for (let className in self.contracts) {
|
|
||||||
self.contracts[className].dependencyCount = null;
|
|
||||||
}
|
|
||||||
self.contractDependencies = {};
|
self.contractDependencies = {};
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
@ -286,43 +283,6 @@ class ContractsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
},
|
|
||||||
function setDependencyCount(callback) {
|
|
||||||
let className;
|
|
||||||
|
|
||||||
function getDependencyCount(contractName, cycleDetector) {
|
|
||||||
if (!self.contracts[contractName]) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (self.contracts[contractName].dependencyCount || self.contracts[contractName].dependencyCount === 0) {
|
|
||||||
// Already have that count
|
|
||||||
return self.contracts[contractName].dependencyCount;
|
|
||||||
}
|
|
||||||
if (!self.contractDependencies[contractName] || !self.contractDependencies[contractName].length) {
|
|
||||||
self.contracts[contractName].dependencyCount = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
let total = self.contractDependencies[contractName].length;
|
|
||||||
self.contractDependencies[contractName].some(dependencyName => {
|
|
||||||
if (cycleDetector.indexOf(dependencyName) > -1) {
|
|
||||||
// We are in a cycle because of the dependency, set both to Infinity
|
|
||||||
self.contracts[dependencyName].dependencyCount = Infinity;
|
|
||||||
total = Infinity;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
cycleDetector.push(dependencyName);
|
|
||||||
total += getDependencyCount(dependencyName, cycleDetector);
|
|
||||||
});
|
|
||||||
self.contracts[contractName].dependencyCount = total;
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
|
|
||||||
let cycleDetector;
|
|
||||||
for (className in self.contracts) {
|
|
||||||
cycleDetector = [];
|
|
||||||
getDependencyCount(className, cycleDetector);
|
|
||||||
}
|
|
||||||
callback();
|
|
||||||
}
|
}
|
||||||
], function (err) {
|
], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user