-
-
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
Changes from 4 commits
1a0f939
18b28e4
1eac915
67a70e6
7806971
c485417
7c1d4b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Get this script after dereferincing all symlinks | ||
# !! Doesn't check for circular symlinks !! | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
source "$DIR/nvm.sh" | ||
'nvm' $@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function nvm --description "Node version manager" -a nvm_command nvm_command_arg1 | ||
set nvm_dir ~/.nvm | ||
set nvm_ $nvm_dir/nvm | ||
|
||
# This sets some environment vars that we need to set too | ||
if test "$nvm_command" = "use" | ||
eval $nvm_ use --print-paths $nvm_command_arg1 | sed -re "s|^(\w+=)|set -x \1|g" -e "s|[=:]| |g" | grep "set -x" | . | ||
else | ||
# Make sure we can use node | ||
if test ! (which node) | ||
# Have we installed node at all ? | ||
if eval $nvm_ ls | grep "N/A" > /dev/null | ||
echo "No node installation found, installing stable" | ||
eval $nvm_ install stable | ||
end | ||
# Make sure we have a default picked | ||
if eval $nvm_ ls default | grep "N/A" | ||
eval $nvm_ alias default stable | ||
end | ||
nvm use default | ||
end | ||
eval $nvm_ $argv | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -531,22 +531,22 @@ nvm() { | |
echo "Node Version Manager" | ||
echo | ||
echo "Usage:" | ||
echo " nvm help Show this message" | ||
echo " nvm --version Print out the latest released version of nvm" | ||
echo " nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available" | ||
echo " nvm uninstall <version> Uninstall a version" | ||
echo " nvm use <version> Modify PATH to use <version>. Uses .nvmrc if available" | ||
echo " nvm run <version> [<args>] Run <version> with <args> as arguments. Uses .nvmrc if available for <version>" | ||
echo " nvm current Display currently activated version" | ||
echo " nvm ls List installed versions" | ||
echo " nvm ls <version> List versions matching a given description" | ||
echo " nvm ls-remote List remote versions available for install" | ||
echo " nvm deactivate Undo effects of NVM on current shell" | ||
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>" | ||
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>" | ||
echo " nvm unalias <name> Deletes the alias named <name>" | ||
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version" | ||
echo " nvm unload Unload NVM from shell" | ||
echo " nvm help Show this message" | ||
echo " nvm --version Print out the latest released version of nvm" | ||
echo " nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available" | ||
echo " nvm uninstall <version> Uninstall a version" | ||
echo " nvm [--print-paths] use <version> Modify PATH (and optionally print it) to use <version>. Uses .nvmrc if available" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would one need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fish calls That has been my experience at least, hence the output of the paths and reapplication nvm.fish#L7 |
||
echo " nvm run <version> [<args>] Run <version> with <args> as arguments. Uses .nvmrc if available for <version>" | ||
echo " nvm current Display currently activated version" | ||
echo " nvm ls List installed versions" | ||
echo " nvm ls <version> List versions matching a given description" | ||
echo " nvm ls-remote List remote versions available for install" | ||
echo " nvm deactivate Undo effects of NVM on current shell" | ||
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>" | ||
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>" | ||
echo " nvm unalias <name> Deletes the alias named <name>" | ||
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version" | ||
echo " nvm unload Unload NVM from shell" | ||
echo | ||
echo "Example:" | ||
echo " nvm install v0.10.24 Install a specific version number" | ||
|
@@ -794,20 +794,35 @@ nvm() { | |
fi | ||
;; | ||
"use" ) | ||
shift # start treating the args given to "use" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After this change, what happens here when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That same as before. The change I made shifts all args left: # nvm [ use --optional version ]
# $@ = [use --optional version] <-- this was checked before
shift
# $@ = [ --optional version] <-- now this is checked If the call is just If the call is just The other check was moved into the following while>case>default. |
||
if [ $# -eq 0 ]; then | ||
nvm help | ||
return 127 | ||
fi | ||
if [ $# -eq 1 ]; then | ||
nvm_rc_version | ||
if [ -n "$NVM_RC_VERSION" ]; then | ||
VERSION=`nvm_version $NVM_RC_VERSION` | ||
fi | ||
elif [ "_$2" != '_system' ]; then | ||
VERSION="$(nvm_version "$2")" | ||
else | ||
VERSION="$2" | ||
# Handle options | ||
while [[ $# > 0 ]]; do | ||
key="$1" | ||
shift | ||
case $key in | ||
--print-paths) | ||
PRINT_PATHS=true | ||
;; | ||
|
||
*) | ||
if [ "_$key" != '_system' ]; then | ||
VERSION="$(nvm_version "$key")" | ||
else | ||
VERSION="$key" | ||
fi | ||
break | ||
;; | ||
esac | ||
done | ||
fi | ||
|
||
if [ -z "$VERSION" ]; then | ||
nvm help | ||
return 127 | ||
|
@@ -822,7 +837,7 @@ nvm() { | |
return 127 | ||
fi | ||
elif [ "_$VERSION" = "_∞" ]; then | ||
echo "The alias \"$2\" leads to an infinite loop. Aborting." >&2 | ||
echo "The alias \"$1\" leads to an infinite loop. Aborting." >&2 | ||
return 8 | ||
fi | ||
|
||
|
@@ -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" ) | ||
|
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.