UNPKG

snyk-nodejs-lockfile-parser

Version:
32 lines 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parsePnpmProject = void 0; const util_1 = require("../util"); const build_dep_graph_pnpm_1 = require("./build-dep-graph-pnpm"); const index_1 = require("./lockfile-parser/index"); const parsePnpmProject = async (pkgJsonContent, pnpmLockContent, options, lockfileVersion) => { const { includeDevDeps, includePeerDeps, includeOptionalDeps, strictOutOfSync, pruneWithinTopLevelDeps, } = options; let importer = ''; const pkgJson = (0, util_1.parsePkgJson)(pkgJsonContent); const lockFileParser = (0, index_1.getPnpmLockfileParser)(pnpmLockContent, lockfileVersion); // Lockfile V9 simple project has the root importer if (lockFileParser.lockFileVersion.startsWith('9')) { importer = '.'; lockFileParser.workspaceArgs = { projectsVersionMap: { '.': { name: pkgJson.name, version: pkgJson.version }, }, isWorkspace: true, }; } const depgraph = await (0, build_dep_graph_pnpm_1.buildDepGraphPnpm)(lockFileParser, pkgJson, { includeDevDeps, strictOutOfSync, includePeerDeps, includeOptionalDeps, pruneWithinTopLevelDeps, }, importer); return depgraph; }; exports.parsePnpmProject = parsePnpmProject; //# sourceMappingURL=parse-project.js.map