-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Notify the user that they're losing access to global modules #631
Notify the user that they're losing access to global modules #631
Conversation
@ljharb I'm taking a second look at this today, and had a thought: switching from I'm wondering if offering a simple, one-line summary of global binaries you're losing every time you switch Nodes isn't a bad idea? I mean, it could get noisy if you know what you're doing, so the way I'm thinking about doing this, is implementing it as a function in Also, I'm new to your codebase; so let me know if you have any stylistic concerns. (I mostly tried to copy what I saw elsewhere in the code.) So, don't merge this yet. Just continuing the conversation with some code. |
Also, I have no idea why the build is failing on Travis. The test I submitted passes locally on dash, bash, and zsh. Am I mis-understanding how your test-suite works? :x |
Travis tests do occasionally fail. If one does, feel free to rerun it and it should pass. I definitely agree that it makes sense that I'm not sure what you mean about the |
# Check whether the user has any globally-installed npm modules in their system | ||
# Node, and warn them if so. | ||
# | ||
nvm_check_global_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.
Please ensure that any nvm_*
functions defined are also added to the unset -f
lists in this file, and/or in nvm.sh
, whichever is appropriate.
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.
(specifically, please add nvm_check_global_modules
to the list in nvm_reset
5aa8f08
to
f3356aa
Compare
I'm still working on this. I ran into a really bad bug. I suspect it is in npm or something, but it's crashing my Terminal every time I run my tests. |
336ee4e
to
058ef81
Compare
@ljharb forgive me for the slow response, I've not had a lot of time at the computer recently.
|
Sure, just did. They do pass for me. I'll make suggestions for debugging/improvement on the test itself, which you can then try in travis. |
|
||
npm install -g nop >/dev/null | ||
message=$(nvm_check_global_modules) | ||
[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed" |
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.
the opposite of ! -z
is -n
.
It may also be helpful here to run it first and do >/dev/null 2>&1
and assert that the output (stderr) is empty (-z
).
Also, let's add $message
into the die output, so we know what it did print out.
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 intentionally using the same check, and negating it, amongst the various tests; I thought that was clearer to a non-initiate (I tend to believe the tests should be accessible to people that the code being tested isn't; as tests should be the entry-point for learning about the codebase). Let me know if this is unwelcome practice, I'll push a switch for
-z
and-n
instead of-z
and! -z
! - I just pushed a bunch of debugging-related output, including showing the actual output of the check command on test failure. Covers this amongst other things~
3f598e3
to
c8efe3d
Compare
@ljharb sorry to take up so much of your time with such a trivial pull. Trying to familiarize myself with Travis as we go along. Edit: Ah, nope, ignore that previous content. It's printing the info. Will keep banging away. <3 |
Okay. I finally tracked down the bugs (I wasn't expecting versions of If you don't like the mini-debugging-framework (compatible with the popular Let me know if you've any other concerns! |
Thanks! Yes, we need to support the npm that ships with every version of node :-) I can see the value of the debugging stuff but I'd rather not keep it in the code. Do you mind rebasing it out? Otherwise I'll merge with the web UI and do a revert of it. |
Notify the user that they're losing access to global modules
This is a continuation of a discussion on #97.
When you install
nvm
, if you have anynpm
modules installed globally (with-g
), they'll no longer be linked to the current install of Node andnpm
, nor is uninstalling them unintuitive.Notifying the user of this fact seems like good practice.