Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
actions.forEach(action => {
const fullyQualifiedDependencies: { [name: string]: dataform.ITarget } = {};
for (const dependency of action.dependencyTargets) {
const possibleDeps = this.findActions(dependency);
if (possibleDeps.length === 0) {
// We couldn't find a matching target.
this.compileError(
new Error(
`Missing dependency detected: Action "${
action.name
}" depends on "${utils.stringifyResolvable(dependency)}" which does not exist.`
),
action.fileName
);
} else if (possibleDeps.length === 1) {
// We found a single matching target, and fully-qualify it if it's a normal dependency,
// or add all of its dependencies to ours if it's an 'inline' table.
const protoDep = possibleDeps[0].proto;
if (protoDep instanceof dataform.Table && protoDep.type === "inline") {
protoDep.dependencyTargets.forEach(inlineDep =>
action.dependencyTargets.push(inlineDep)
);
} else {
fullyQualifiedDependencies[protoDep.name] = protoDep.target;
}
} else {
// Too many targets matched the dependency.
newDependencies.forEach((d: Resolvable) => {
const depName = utils.stringifyResolvable(d);
if (this.proto.dependencies.indexOf(depName) < 0) {
this.proto.dependencies.push(depName);
}
});
return this;
newDependencies.forEach((d: Resolvable) => {
const depName = utils.stringifyResolvable(d);
if (this.proto.dependencies.indexOf(depName) < 0) {
this.proto.dependencies.push(depName);
}
});
return this;
private addDependency(dependency: Resolvable): void {
const depName = utils.stringifyResolvable(dependency);
if (this.proto.dependencies.indexOf(depName) < 0) {
this.proto.dependencies.push(depName);
}
}
}