MCPcopy
hub / github.com/ember-cli/ember-cli / countAddons

Function countAddons

tests/helpers/per-bundle-addon-cache.js:75–100  ·  view source on GitHub ↗

* For a given project/addon, this counts addon instances within said project/addon; * specifically we're interested in the number of "real" addon instances, and proxy * objects. * * @name countAddons * @param {Project|Addon} projectOrAddon * @param {Object} [config] * @returns {{byName: Objec

(projectOrAddon, config = { byName: {}, proxyCount: 0, realAddonInstanceCount: 0 })

Source from the content-addressed store, hash-verified

73 * @returns {{byName: Object, proxyCount: number, realAddonInstanceCount: number}}
74 */
75function countAddons(projectOrAddon, config = { byName: {}, proxyCount: 0, realAddonInstanceCount: 0 }) {
76 projectOrAddon.addons.forEach((addon) => {
77 const addonName = addon.name;
78
79 if (!config.byName[addonName]) {
80 config.byName[addonName] = {
81 addons: [],
82 proxyCount: 0,
83 realAddonInstanceCount: 0,
84 };
85 }
86
87 if (addon[TARGET_INSTANCE]) {
88 config.proxyCount++;
89 config.byName[addonName].proxyCount++;
90 } else {
91 config.realAddonInstanceCount++;
92 config.byName[addonName].realAddonInstanceCount++;
93 }
94
95 config.byName[addonName].addons.push(addon);
96 countAddons(addon, config);
97 });
98
99 return config;
100}
101
102/**
103 * Generate the file structure used for the cache-bundle-hosts and enable-cache tests.

Callers 1

proxy-test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…