nvm/nvm.fish
LoveIsGrief 1eac915fba Introduce nvm function for fish
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.
2014-11-15 22:41:05 +01:00

25 lines
800 B
Fish

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