-
Notifications
You must be signed in to change notification settings - Fork 804
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
Add hooks system for packages #286
Conversation
I always wanted install and update hooks! This hooks are very useful for Git submodule usage or other custom code that runs only once after install/update. I see lots of use cases for this! I had a fast review of the PR, and I raised some concerns about the concepts:
Aside from this concerns I love your initiative! Thanks for such PR 🎉 |
Thanks for the feedback. Let me address each of your points:
|
I was going to reinforce @derekstavis concerns regarding the double update and the subshell invocation, but you got there first. What concerns me the most right now is that I'm still not convinced about use cases. |
I don't believe submodules should be a common thing to deserve a implementation inside the framework. For example, nvm and rvm plugins should depend on user-installed dependencies, instead of bundling them using submodules. |
Then the question remains: which type of packages do need submodules? or the other hooks for any purpose? |
Mostly packages that have third-party shell scripts, like spark or fasd. Using submodules has the advantage of reducing the number of install / update steps, since otherwise you need to download a shell script by hand and put it in the path somewhere. And since it's just shell scripts, compilation, compilers, interpreters, etc. are not a concern. Now things that need binaries should probably avoid submodules, since it would be better to install the binaries with the system package manager. |
Just pushed a commit that improves the following:
|
The code looks great now IMO. |
@@ -0,0 +1,20 @@ | |||
function omf.packages.hook -a path hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not being nitpicky, but omf.packages.hook.run
sounds more descriptive regarding to the action which the function performs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. How about omf.packages.run_hook
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was my second option 😝
Renamed |
Im 👌 for merging |
This pull request adds a new (or rather, revamped) "hooks" system for packages to tap into during the package's lifetime. Similar to Git hooks, OMF hooks are Fish shell scripts located in a
hooks/
directory inside a package. When a particular hook is triggered, the corresponding script is run, if it exists.The following hooks are implemented:
install
; Triggered when the package is first installed viaomf install
. Useful for installing custom dependencies.update
: Triggered when the package is being updated viaomf update
. Useful for updating submodules, etc.uninstall
: Triggered when the package is removed viaomf remove
. Subscribers can use the event to clean up custom resources, etc.For consistency, the
uninstall
hook is now in thehooks/
directory, same as the other hooks.This PR has a weird relationship with #260; it may or may not need to be merged after #260 is. It is based off of
master
though.Only the English docs are updated; the docs team can update translations separately if this is merged.