Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function() {
// Check for cycles in the graph, the dependency graph needs to be a tree otherwise there's an error
if (!isAcyclic(dependsGraph)) {
var errorMessage = "Found cyclic dependencies. Adjust your import statements to remove cycles.\n\n";
dependsGraph.edges().forEach(function(o){
errorMessage += o.v + " -- depends on --> " + o.w + "\n";
});
return callback(new CompileError(errorMessage));
}
callback(null, dependsGraph)
});
},
for (var i = 0; i < contracts.length; i++) {
var contract = contracts[i];
var contractName = contract.name;
if (!g.hasNode(contractName)) {
g.setNode(contractName);
}
var deps = getDependencies(contract);
for (var j = 0; j < deps.length; j++) {
var depName = deps[j];
if (!g.hasNode(depName)) {
g.setNode(depName);
}
g.setEdge(contractName, depName);
if (!GraphAlgorithms.isAcyclic(g)) {
throw new Error('Dependency ' + contractName + ' -> ' + depName + ' inroduces cycle');
}
}
}
return g;
}