npm-link-up
Version:
Use this package to link your projects together for local development.
47 lines (46 loc) • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
exports.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 = utils_1.getPath(map, newMap[v], opts);
list.forEach(l => {
getRelevantItems(mapPath(l));
});
}
};
getRelevantItems(mainDep.path);
return newMap;
};
exports.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.getCleanMapOfOnlyPackagesWithNluJSONFiles = (rootPackageName, map) => {
return Object.keys(map).reduce((a, b) => {
if (map[b].hasNLUJSONFile) {
a[b] = map[b];
}
return a;
}, {});
};