UNPKG

npm-link-up

Version:

Use this package to link your projects together for local development.

51 lines (50 loc) 1.79 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCleanMapOfOnlyPackagesWithNluJSONFiles = exports.getCleanMap2 = exports.getCleanMap = void 0; const utils_1 = require("./utils"); const getCleanMap = (mainDep, map, opts) => { const newMap = {}; const getRelevantItems = (v) => { if (map[v] && !newMap[v]) { newMap[v] = map[v]; const list = map[v].deps; if (!Array.isArray(list)) { throw new Error('list should be an array, but is not an array type: ' + JSON.stringify(map[v])); } const mapPath = (0, utils_1.getPath)(map, newMap[v], opts); list.forEach(l => { getRelevantItems(mapPath(l)); }); } }; getRelevantItems(mainDep.path); return newMap; }; exports.getCleanMap = getCleanMap; const getCleanMap2 = (rootPackageName, map) => { const newMap = {}; const getRelevantItems = (v) => { if (map[v] && !newMap[v]) { newMap[v] = map[v]; const list = map[v].deps; if (!Array.isArray(list)) { throw new Error('list should be an array, but is not an array type: ' + JSON.stringify(map[v])); } list.forEach(function (l) { getRelevantItems(l); }); } }; getRelevantItems(rootPackageName); return newMap; }; exports.getCleanMap2 = getCleanMap2; const getCleanMapOfOnlyPackagesWithNluJSONFiles = (rootPackageName, map) => { return Object.keys(map).reduce((a, b) => { if (map[b].hasNLUJSONFile) { a[b] = map[b]; } return a; }, {}); }; exports.getCleanMapOfOnlyPackagesWithNluJSONFiles = getCleanMapOfOnlyPackagesWithNluJSONFiles;