-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Post install hook #1342
Post install hook #1342
Conversation
If this is likely to be accepted I can add it to the readme, showing how to use it to install global node modules. |
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.
Thanks for the exploratory PR.
I'm not yet decided on whether it's better to allow a generic hook - or whether it's better to just allow a default --reinstall-packages-from
(via an env var).
@@ -2464,6 +2464,10 @@ nvm() { | |||
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then | |||
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM" | |||
fi | |||
if [ ! -z "${NVM_POST_INSTALL-}" ]; then | |||
nvm_echo 'Running post install hook.' | |||
$NVM_POST_INSTALL |
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.
this should probably run in a subshell so that it can't interfere with nvm
's operation
- NVM_POST_INSTALL env variable is executed after `nvm install` if it is set
567f318
to
827c7ba
Compare
I find the I think having a specified set of global modules is nice and would prevent every node version having global modules you don't really use that often. If there was a default |
It certainly would be more complicated for your use case - but most importantly, it would be less rife for abuse than a generic hook :-/ I'll think on it more. |
@ljharb just wondering if there were any more thoughts on this? Personally feel like its a useful feature |
I'm still concerned with the potential for abuse, compared with the low-cost current requirement to do |
The post install allows us to setup installing global modules pretty easily though, without much thought. It would be useful to do it that way rather than remembering to do it after every install. |
Once your global packages are set up once, |
@roberttod it seems like #1463 might cover your use case a bit better? |
NVM_POST_INSTALL
env variable is executed afternvm install
if it is setUsing the hook install global npm modules
Just add the
NVM_POST_INSTALL
variable to.bash_profile
, installing global modules that are used frequently.