[Proposal] Option to ensure plugin hooks are executed AFTER the root CLI's hooks #823
Replies: 3 comments
-
@william-will-angi So essentially you want the option to execute hooks based on some order? There is some precedence for this in how we determine which command to execute when two different plugins define the same command: https://github.com/oclif/core/blob/v1.9.5/src/config/config.ts#L680 The same or similar logic could be applied to hooks. It might be as simple as sorting the plugins here https://github.com/oclif/core/blob/v1.9.5/src/config/config.ts#L275 If that approach works, I don't believe either of the downsides you listed will be an issue |
Beta Was this translation helpful? Give feedback.
-
Thank you for the speedy reply! Executing the hooks in a specific order is part of what we're looking for, but we also want to be able to configure resolution order as well. For a bit more context: In general, we do want our |
Beta Was this translation helpful? Give feedback.
-
I see. Thanks for the clarification. I have a few thoughts:
Generally speaking, I'd prefer if you were able to make either of the first two work for you since it would mean less code to maintain and fewer features to document. But if you decide you need the 3rd option or some variation of it, you'll need to submit the PR yourself as we don't have the ability to prioritize it on our side at this time. However, I'm more than happy to review it whenever it's ready |
Beta Was this translation helpful? Give feedback.
-
We have a root CLI set up with a handful of
plugin-plugins
that can be installed alongside it. Our root CLI currently has its owninit
hooks that need be executed.We now want to implement some init hooks within our
plugin-plugins
. BUT, we want to ensure any plugin hooks are executed after the root CLI's hooks, because some of them are dependent on the setup that our root CLI provides.In the short-term, we will likely implement a custom event (maybe called
plugins:init
) that plugins can use to ensure they are executed after the root CLI has initialized. There are two downsides to this approach from what I can see:I think it would be a bit cleaner to allow an option that ensures order is preserved. Is this a possible feature that could be implemented?
Beta Was this translation helpful? Give feedback.
All reactions