UNPKG

workspace-tools

Version:

A collection of tools that are useful in a git-controlled monorepo that is managed by one of these software:

27 lines (26 loc) 791 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const dependencies_1 = require("./dependencies"); const graphCache = new Map(); function getPackageGraph(packages) { if (graphCache.has(packages)) { return graphCache.get(packages); } const edges = []; for (const [pkg, info] of Object.entries(packages)) { const deps = dependencies_1.getInternalDeps(info, packages); for (const dep of deps) { edges.push([dep, pkg]); } } graphCache.set(packages, edges); return edges; } exports.getPackageGraph = getPackageGraph; /** * @internal resets the graph cache for internal testing purpose only */ function _resetGraphCache() { graphCache.clear(); } exports._resetGraphCache = _resetGraphCache;