-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
bash_completion fixes #1375
bash_completion fixes #1375
Conversation
@@ -2,6 +2,10 @@ | |||
|
|||
# bash completion for Node Version Manager (NVM) | |||
|
|||
if ! nvm &> /dev/null; then | |||
return |
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.
should this error out, instead of just returning?
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.
Refer to the common bash_completions, I think it's fine to just silently do nothing, but we can print error message if you want.
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.
I guess this is fine as-is.
install.sh
Outdated
@@ -306,7 +306,7 @@ nvm_do_install() { | |||
command printf "${SOURCE_STR}" | |||
else | |||
case "${NVM_PROFILE-}" in | |||
".bashrc" | ".bash_profile" | ".zshrc") | |||
*"/.bashrc" | *"/.bash_profile" | *"/.zshrc") |
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.
How did this work in your original testing? Can we add "install script" tests that would have caught this?
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.
Since I can't run the tests locally, I might mess it up when manually mocking up the variables, or something like that, I'll be happy to write test, which part would you like to have?
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.
Ideally I'd like a test that fails without the */
, and passes with it.
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.
Then should we separate this part of detection out to a single function?
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.
It's already in nvm_do_install
- if that's not tested or is hard to test, then splitting it into a separate function is fine.
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 sure if I understand it, looks like test/install_script/nvm_do_install
is just for testing nvm_do_install
function available?
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.
Right - so let's refactor out the detection into a separate function, and make tests just for it.
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.
@ljharb updated! would you please help me review? Thanks!
c6c8015
to
8f92ae5
Compare
18eaabf
to
f8fd9bf
Compare
f8fd9bf
to
56e29db
Compare
Hello @ljharb, is the update fine with you 😄 ? Thanks. |
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, looks good. It'd be good to rebase this down to one commit on latest master, but I can take care of it when I get a chance to merge it if you don't have the time :-)
56e29db
to
e8372be
Compare
@ljharb no problem, branch rebased, hope could be merged this time, thanks. |
e8372be
to
270a872
Compare
270a872
to
952d006
Compare
NVM_PROFILE
will be a full path, the detection was not working properly without*/
prefix.Which will cause this error if you don't manually remove the comment:
Which is inconvenient, so I removed the
&&
prefix, and let thebash_completion
to detect ifnvm
loaded.nvm
already loaded or not, so it'll work even ifnvm
is not loaded, now it'll detect ifnvm
loaded yet.