Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dependencies across directories #415

Merged
merged 2 commits into from
Oct 8, 2024
Merged
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
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ const fastifyAutoload = async function autoload (fastify, options) {
}

async function loadPlugins ({ pluginTree, options, opts, fastify }) {
const nodes = []
const pluginsMeta = {}
for (const key in pluginTree) {
const node = {
...pluginTree[key],
pluginsMeta: {},
pluginsMeta,
hooksMeta: {}
}
nodes.push(node)

await Promise.all(node.plugins.map(({ file, type, prefix }) => {
return loadPlugin({ file, type, directoryPrefix: prefix, options: opts, log: fastify.log })
Expand All @@ -55,7 +58,9 @@ async function loadPlugins ({ pluginTree, options, opts, fastify }) {
throw enrichError(err)
})
}))
}

for (const node of nodes) {
registerNode(node, fastify)
}
}
Expand Down