MCPcopy Create free account
hub / github.com/ember-cli/ember-cli / addPackages

Method addPackages

lib/models/package-info-cache/package-info.js:291–316  ·  view source on GitHub ↗

* Add to a list of child addon PackageInfos for this packageInfo. * * @method addPackages * @param {Array} addonPackageList the list of child addon PackageInfos being constructed from various * sources in this packageInfo. * @param {Array | Object} packageInfoList a list or map of Pac

(addonPackageList, packageInfoList, excludeFn)

Source from the content-addressed store, hash-verified

289 * returns a truthy value.
290 */
291 addPackages(addonPackageList, packageInfoList, excludeFn) {
292 if (!packageInfoList) {
293 return;
294 }
295
296 let result = [];
297 if (Array.isArray(packageInfoList)) {
298 if (excludeFn) {
299 packageInfoList = packageInfoList.filter((pkgInfo) => !excludeFn(pkgInfo));
300 }
301
302 packageInfoList.forEach((pkgInfo) => result.push(pkgInfo));
303 } else {
304 // We're going to assume we have a map of name to packageInfo
305 Object.keys(packageInfoList).forEach((name) => {
306 let pkgInfo = packageInfoList[name];
307 if (!excludeFn || !excludeFn(pkgInfo)) {
308 result.push(pkgInfo);
309 }
310 });
311 }
312
313 result.sort(lexicographically).forEach((pkgInfo) => pushUnique(addonPackageList, pkgInfo));
314
315 return addonPackageList;
316 }
317
318 /**
319 * Discover the child addons for this packageInfo, which corresponds to an Addon.

Callers 2

discoverAddonAddonsMethod · 0.95
discoverProjectAddonsMethod · 0.95

Calls 2

pushUniqueFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected