Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions core/cli/src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function asyncFilter<T>(items: T[], predicate: (item: T) => Promise<boolea
return results.filter(({ keep }) => keep).map(({ item }) => item)
}

const loadHookEntrypoints = async (
export const loadHookEntrypoints = async (
logger: Logger,
config: ValidConfig
): Promise<Validated<Record<string, HookModule>>> => {
Expand All @@ -54,13 +54,9 @@ export const loadHookInstallations = async (
config: ValidConfig
): Promise<Validated<Hook[]>> => {
const hookClassResults = await loadHookEntrypoints(logger, config)
const installationResults = (
await hookClassResults
.map((hookClasses) =>
reducePluginHookInstallations(logger, config, hookClasses, config.plugins['app root'])
)
.awaitValue()
).flatMap((installation) => installation)
const installationResults = hookClassResults.flatMap((hookClasses) =>
reducePluginHookInstallations(logger, config, hookClasses, config.plugins['app root'])
)

const installationsWithoutConflicts = installationResults.flatMap((installations) => {
const conflicts = findConflicts(installations)
Expand Down
10 changes: 3 additions & 7 deletions core/cli/src/plugin/reduce-installations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,19 @@ const extractForHook = (installation: HookInstallation | Conflict<HookInstallati
// - call `Hook.overrideChildInstallations` with the appropriate concrete Hook class, and

// the resulting installations and/or conflicts from `Hook.mergeChildInstallations` and `p`
export async function reducePluginHookInstallations(
export function reducePluginHookInstallations(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what was the original reason for making this function async? performance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have been trying to work it out; i think originally i was thinking that the merge/override methods might need to be async? but they don't

logger: Logger,
config: ValidConfig,
hookModules: Record<string, HookModule>,
plugin: Plugin
): Promise<Validated<(HookInstallation | Conflict<HookInstallation>)[]>> {
): Validated<(HookInstallation | Conflict<HookInstallation>)[]> {
if (!plugin.rcFile || config.resolutionTrackers.reducedInstallationPlugins.has(plugin.id)) {
return valid([])
}
config.resolutionTrackers.reducedInstallationPlugins.add(plugin.id)

const rawChildInstallations = reduceValidated(
await Promise.all(
(plugin.children ?? []).map((child) =>
reducePluginHookInstallations(logger, config, hookModules, child)
)
)
(plugin.children ?? []).map((child) => reducePluginHookInstallations(logger, config, hookModules, child))
).map((installations) => installations.flat())

if (!rawChildInstallations.valid) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins:
- './a'
- './b'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2

options:
hooks:
- TestHook:
a: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2

options:
hooks:
- TestHook:
b: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
plugins:
- './b'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2

options:
hooks:
- TestHook:
a: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2

plugins:
- '../a'

options:
hooks:
- TestHook:
b: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins:
- './a'
- './b'

options:
hooks:
- TestHook:
c: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2

options:
hooks:
- TestHook:
a: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2

options:
hooks:
- TestHook:
b: true
Loading