* 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: [] })
| 17 | * @returns {{proxies: Proxy[], realAddon: Addon}} |
| 18 | */ |
| 19 | function 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 |
no test coverage detected
searching dependent graphs…