@snyk/dep-graph
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -7,5 +7,6 @@ "use strict"; | ||
var builder_1 = require("../core/builder"); | ||
var event_loop_spinner_1 = require("./event-loop-spinner"); | ||
function depTreeToGraph(depTree, pkgManagerName) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var rootPkg, pkgManagerInfo, targetOS, builder, depGraph; | ||
var rootPkg, pkgManagerInfo, targetOS, builder, eventLoopSpinner, depGraph; | ||
return tslib_1.__generator(this, function (_a) { | ||
@@ -30,3 +31,4 @@ switch (_a.label) { | ||
builder = new builder_1.DepGraphBuilder(pkgManagerInfo, rootPkg); | ||
return [4 /*yield*/, buildGraph(builder, depTree, depTree.name, true)]; | ||
eventLoopSpinner = new event_loop_spinner_1.EventLoopSpinner(); | ||
return [4 /*yield*/, buildGraph(builder, depTree, depTree.name, eventLoopSpinner, true)]; | ||
case 1: | ||
@@ -37,3 +39,3 @@ _a.sent(); | ||
depGraph = _a.sent(); | ||
return [2 /*return*/, shortenNodeIds(depGraph)]; | ||
return [2 /*return*/, shortenNodeIds(depGraph, eventLoopSpinner)]; | ||
} | ||
@@ -44,3 +46,3 @@ }); | ||
exports.depTreeToGraph = depTreeToGraph; | ||
function buildGraph(builder, depTree, pkgName, isRoot) { | ||
function buildGraph(builder, depTree, pkgName, eventLoopSpinner, isRoot) { | ||
if (isRoot === void 0) { isRoot = false; } | ||
@@ -63,3 +65,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
dep = deps[depName]; | ||
return [4 /*yield*/, buildGraph(builder, dep, depName)]; | ||
return [4 /*yield*/, buildGraph(builder, dep, depName, eventLoopSpinner)]; | ||
case 2: | ||
@@ -96,4 +98,4 @@ subtreeHash = _c.sent(); | ||
} | ||
if (!(depNodesIds.length > 0)) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, spinTheEventLoop()]; | ||
if (!(depNodesIds.length > 0 && eventLoopSpinner.isStarving())) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, eventLoopSpinner.spin()]; | ||
case 5: | ||
@@ -107,3 +109,3 @@ _c.sent(); | ||
} | ||
function shortenNodeIds(depGraph) { | ||
function shortenNodeIds(depGraph, eventLoopSpinner) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -137,3 +139,4 @@ var builder, nodesMap, _i, _a, pkg, nodeIds, i, nodeId, newNodeId, _b, _c, pkg, _d, _e, nodeId, _f, _g, depNodeId, parentNode, childNode; | ||
} | ||
return [4 /*yield*/, spinTheEventLoop()]; | ||
if (!eventLoopSpinner.isStarving()) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, eventLoopSpinner.spin()]; | ||
case 2: | ||
@@ -160,3 +163,4 @@ _h.sent(); | ||
} | ||
return [4 /*yield*/, spinTheEventLoop()]; | ||
if (!eventLoopSpinner.isStarving()) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, eventLoopSpinner.spin()]; | ||
case 6: | ||
@@ -175,3 +179,3 @@ _h.sent(); | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var depGraph, depTree, targetOS; | ||
var depGraph, eventLoopSpinner, depTree, targetOS; | ||
return tslib_1.__generator(this, function (_a) { | ||
@@ -185,3 +189,4 @@ switch (_a.label) { | ||
} | ||
return [4 /*yield*/, buildSubtree(depGraph, depGraph.rootNodeId)]; | ||
eventLoopSpinner = new event_loop_spinner_1.EventLoopSpinner(); | ||
return [4 /*yield*/, buildSubtree(depGraph, depGraph.rootNodeId, eventLoopSpinner)]; | ||
case 1: | ||
@@ -220,3 +225,3 @@ depTree = _a.sent(); | ||
} | ||
function buildSubtree(depGraph, nodeId) { | ||
function buildSubtree(depGraph, nodeId, eventLoopSpinner) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -240,3 +245,3 @@ var nodePkg, depTree, depInstanceIds, _i, depInstanceIds_1, depInstId, subtree; | ||
depInstId = depInstanceIds_1[_i]; | ||
return [4 /*yield*/, buildSubtree(depGraph, depInstId)]; | ||
return [4 /*yield*/, buildSubtree(depGraph, depInstId, eventLoopSpinner)]; | ||
case 2: | ||
@@ -255,6 +260,9 @@ subtree = _a.sent(); | ||
return [3 /*break*/, 1]; | ||
case 4: return [4 /*yield*/, spinTheEventLoop()]; | ||
case 4: | ||
if (!eventLoopSpinner.isStarving()) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, eventLoopSpinner.spin()]; | ||
case 5: | ||
_a.sent(); | ||
return [2 /*return*/, depTree]; | ||
_a.label = 6; | ||
case 6: return [2 /*return*/, depTree]; | ||
} | ||
@@ -264,9 +272,2 @@ }); | ||
} | ||
function spinTheEventLoop() { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve) { return setImmediate(resolve); })]; | ||
}); | ||
}); | ||
} | ||
function trimAfterLastSep(str, sep) { | ||
@@ -273,0 +274,0 @@ return str.slice(0, str.lastIndexOf(sep)); |
@@ -45,3 +45,3 @@ { | ||
}, | ||
"version": "1.4.0" | ||
"version": "1.4.1" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57321
36
810