-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
303 nvm in fish #579
303 nvm in fish #579
Conversation
It will print all paths that have been changed by nvm use. These paths are exported for all later nvm commands and need to be applied to the environment of other shells (in this case fish), therefore they are printed with the option.
nvm.sh isn't executable so this file was introduced. It dereferences symlinks for e.g `ln -s ~/.nvm/nvm ~/bin/nvm` will now work.
This is a wrapper around nvm. It's main function is to check and promote environment variables changes from nvm to fish. A little more is done to setup the environment in case that hasn't been done yet: * install a stable node version if it doesn't exist * set the default to stable alias if that hasn't been done yet Due to those actions, the first execution of `nvm` might take some time.
Fish has to be configured to use nvm. Basically 2 actions have to be taken (like with bash and others): 1. Introduce the nvm function 2. Execute the nvm function once the shell is loaded to have access to nodejs The first session with fish might take a while to start, if nvm doesn't have its default env (stable nodejs + default alias)
Per #303, https://github.com/Alex7Kom/nvm-fish works well in If I was inclined, it would need to be accompanied by test suite changes so that the full suite of tests were run in |
@@ -1,5 +1,15 @@ | |||
#!/bin/bash | |||
|
|||
# Get this script after dereferincing all symlinks | |||
# !! Doesn't check for circular symlinks !! |
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 is a pretty big caveat. Can it be avoided? Why is this necessary?
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.
Oops, sorry. That's for the vagrant PR #578 . It isn't used in this one. I'll remove it.
The DIR variable is used in another branch (vagrant) and doesn't belong here
…bles.' work again /bin/sh doesn't like `while [[ ... ]]`. It much rather prefers `while [ .. ]` Also minor spacing changes
…k again Slight problem with the output. The test expected an alias to be returned, but an empty string was returned.
Related: #582 My PR is not shell specific, but will work with fish or any other shell |
Now that |
I'm not sure what could be simplified. @@ -858,6 +873,12 @@ nvm() {
if [ "$NVM_SYMLINK_CURRENT" = true ]; then
rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
fi
+ if [ $PRINT_PATHS ]; then
+ echo PATH=$PATH
+ echo NODE_PATH=$NODE_PATH
+ echo NVM_PATH=$NVM_PATH
+ echo NVM_BIN=$NVM_BIN
+ fi
echo "Now using node $VERSION"
;;
"run" ) |
A small, separate PR for I'd wait a couple of days, though, as my imminent |
Closing this for now. |
Hi,
Related to #303 , I use fish myself and love that I can run
npm install -g <...>
with nvm --> fish nvm was needed.This is simply a wrapper around nvm for fish. I have commented my commits as much as possible to help understand my thought process. I hope others with fish can test this (tests in vagrant worked for me).
A wrapper allows nvm to change below without (hopefully) affecting functionality in fish.
I'm open to critical feedback or improvement suggestions.
Cheers