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

refactor(auto-reshim): add npm wrapper and remove npm hooks #232

Merged
merged 8 commits into from
Jul 19, 2021

Conversation

augustobmoura
Copy link
Member

Instead of relying in npm global installation hook for auto reshimming,
a pretty obscure functionality of npm, I just wrote a wrapper script
that intercept calls for npm and invokes asdf reshim whenever necessary.

The wrapper needs to be configured manually by the user, following the
practices of other plugins with similar settings.

I also wrote an utility for printing the current wrapper path easing the
configuration of new environments.

README now has an example of how to configure auto-reshimming.

There's also a notice on plugin installation about setting up the
auto-reshimming configuration.

A notice was also added to the install command, so that we reach more
people about the changes.

augustobmoura and others added 4 commits May 16, 2021 21:06
Instead of relying in npm global installation hook for auto reshimming,
a pretty obscure functionality of npm, I just wrote a wrapper script
that intercept calls for npm and invokes asdf reshim whenever necessary.

The wrapper needs to be configured manually by the user, following the
practices of other plugins with similar settings.

I also wrote an utility for printing the current wrapper path easing the
configuration of new environments.

README now has an example of how to configure auto-reshimming.

There's also a notice on plugin installation about setting up the
auto-reshimming configuration.

A notice was also added to the install command, so that we reach more
people about the changes.
@augustobmoura
Copy link
Member Author

@Stratus3D can you check this PR? I don't know if we tried this before, but it seems like the best way of keeping auto-reshimming in the new npm versions. What do you think?

Now we are using a shim template, we find the true binary in the path
and then call asdf reshim only when necessary
@augustobmoura
Copy link
Member Author

I changed how the wrapper works. Now it is a shim template, it will find the true npm executable and calls asdf reshim only when necessary and always after every package is installed

fixes #227, #226, #89, #47, #46

@augustobmoura
Copy link
Member Author

It also invalidates #118 and #197

@augustobmoura
Copy link
Member Author

augustobmoura commented Jul 19, 2021

It seems like NodeJS is deprecating node_modules/.hooks indefinitely as of npm 7+ , even though it might get re-implemented in the future, the already released versions will never work with our hooks. Because of that, I will push this PR as soon as possible as I don't see any other future proof way of auto reshimming on install without wrapping the npm command in a script

@augustobmoura augustobmoura merged commit c0f37e2 into asdf-vm:master Jul 19, 2021
@augustobmoura augustobmoura deleted the feature/npm-wrapper branch July 19, 2021 22:32
.gitignore Show resolved Hide resolved
@Stratus3D
Copy link
Member

Thanks for all your work on this @augustobmoura ! Hoping these changes will make things easier for people!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants