MCPcopy Index your code
hub / github.com/ember-cli/ember-cli / getAllAddonsByNameWithinHost

Function getAllAddonsByNameWithinHost

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

* This collects all addons by name within a given host; it stops traversing when it * encounters another host (i.e., a lazy engine). Within a given host we should expect * at most 1 real addon, otherwise this is an error condition. We otherwise add all * proxies to `config.proxies` * * @name ge

(projectOrAddon, addonName, config = { proxies: [] })

Source from the content-addressed store, hash-verified

17 * @returns {{proxies: Proxy[], realAddon: Addon}}
18 */
19function getAllAddonsByNameWithinHost(projectOrAddon, addonName, config = { proxies: [] }) {
20 if (!config.originalHost) {
21 config.originalHost = projectOrAddon;
22 }
23
24 projectOrAddon.addons.forEach((addon) => {
25 if (addon.name === addonName) {
26 if (config.realAddon && !addon[TARGET_INSTANCE]) {
27 throw new Error(
28 `The real addon (\`${addon.name}\`) has already been set for a given host (\`${
29 typeof config.originalHost.name === 'function' ? config.originalHost.name() : config.originalHost.name
30 }\`); the proxy for addon caching is not working correctly`
31 );
32 }
33
34 if (addon[TARGET_INSTANCE]) {
35 config.proxies.push(addon);
36 } else {
37 config.realAddon = addon;
38 }
39 }
40
41 // stop traversing within another host
42 if (!isLazyEngine(addon)) {
43 getAllAddonsByNameWithinHost(addon, addonName, config);
44 }
45 });
46
47 return config;
48}
49
50/**
51 * Returns whether all instances within a given host are equal (i.e., that there's a single

Callers 2

proxy-test.jsFile · 0.85

Calls 1

nameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…