"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1280.1/src/lib/monitor/prune-dep-tree.ts" (20 Feb 2024, 681 Bytes) of package /linux/misc/snyk-cli-1.1280.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import * as depGraphLib from '@snyk/dep-graph';
    2 import { DepTree } from '../types';
    3 
    4 export async function pruneTree(
    5   tree: DepTree,
    6   packageManagerName: string,
    7 ): Promise<DepTree> {
    8   // Pruning requires conversion to the graph first.
    9   // This is slow.
   10   const graph = await depGraphLib.legacy.depTreeToGraph(
   11     tree,
   12     packageManagerName,
   13   );
   14   const prunedTree: DepTree = (await depGraphLib.legacy.graphToDepTree(
   15     graph,
   16     packageManagerName,
   17     { deduplicateWithinTopLevelDeps: true },
   18   )) as DepTree;
   19   // Transplant pruned dependencies in the original tree (we want to keep all other fields):
   20   tree.dependencies = prunedTree.dependencies;
   21   return tree;
   22 }