Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dag.setNode(ROOT_NODE_NAME)
dag = reduce(
(accum, instanceId) => {
if (instanceId !== ROOT_NODE_NAME) {
accum.setEdge(instanceId, ROOT_NODE_NAME)
}
return accum
},
dag,
dag.sinks()
)
// checking for circular dependencies
const isAcyclic = alg.isAcyclic(dag)
if (!isAcyclic) {
const cycles = alg.findCycles(dag)
let msg = ['Your serverless.yml file has circular dependencies:']
cycles.forEach((cycle, index) => {
let fromAToB = cycle.join(' --> ')
fromAToB = `${(index += 1)}. ${fromAToB}`
const fromBToA = cycle.reverse().join(' <-- ')
const padLength = fromAToB.length + 4
msg.push(fromAToB.padStart(padLength))
msg.push(fromBToA.padStart(padLength))
}, cycles)
msg = msg.join('\n')
throw new Error(msg)
}
return dag
}
const validateGraph = graph => {
const isAcyclic = alg.isAcyclic(graph);
if (!isAcyclic) {
const cycles = alg.findCycles(graph);
let msg = ["Your installers have circular dependencies:"];
cycles.forEach((cycle, index) => {
let fromAToB = cycle.join(" --> ");
fromAToB = `${(index += 1)}. ${fromAToB}`;
const fromBToA = cycle.reverse().join(" <-- ");
const padLength = fromAToB.length + 4;
msg.push(fromAToB.padStart(padLength));
msg.push(fromBToA.padStart(padLength));
}, cycles);
msg = msg.join("\n");
throw new Error(msg);
}
};
check() {
const cycleGroups = alg.findCycles(this.graph);
if (cycleGroups.length > 0) {
const cycles = cycleGroups.map(printCycleGroups).join("\n");
if (debugExecute.enabled) {
debugExecute(`Execution plan dependencies:\n${this.print()}`);
}
throw new UserError(`There are circular dependencies present in this deployment:\n${cycles}`);
}
}
const validateGraph = graph => {
const isAcyclic = alg.isAcyclic(graph);
if (!isAcyclic) {
const cycles = alg.findCycles(graph);
let msg = ["Your template has circular dependencies:"];
cycles.forEach((cycle, index) => {
let fromAToB = cycle.join(" --> ");
fromAToB = `${(index += 1)}. ${fromAToB}`;
const fromBToA = cycle.reverse().join(" <-- ");
const padLength = fromAToB.length + 4;
msg.push(fromAToB.padStart(padLength));
msg.push(fromBToA.padStart(padLength));
}, cycles);
msg = msg.join("\n");
throw new Error(msg);
}
};
const validateGraph = graph => {
const isAcyclic = alg.isAcyclic(graph);
if (!isAcyclic) {
const cycles = alg.findCycles(graph);
let msg = ["Your installers have circular dependencies:"];
cycles.forEach((cycle, index) => {
let fromAToB = cycle.join(" --> ");
fromAToB = `${index + 1}. ${fromAToB}`;
const fromBToA = cycle.reverse().join(" <-- ");
const padLength = fromAToB.length + 4;
msg.push(fromAToB.padStart(padLength));
msg.push(fromBToA.padStart(padLength));
}, cycles);
msg = msg.join("\n");
throw new Error(msg);
}
};
findCycles() {
return alg.findCycles(this._graph);
}