Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions libexec/nodenv-init
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,52 @@ is_fish && {
echo 'export PATH="'${NODENV_ROOT}'/shims:${PATH}"'
echo 'nodenv rehash 2>/dev/null'
}

commands=(`nodenv-commands --sh`)
case "$shell" in
fish )
cat <<EOS
function nodenv
set command \$argv[1]
set -e argv[1]

switch "\$command"
case ${commands[*]}
eval (nodenv "sh-\$command" \$argv)
case '*'
command nodenv "\$command" \$argv
end
end
EOS
;;
ksh )
cat <<EOS
function nodenv {
typeset command
EOS
;;
* )
cat <<EOS
nodenv() {
local command
EOS
;;
esac

if [ "$shell" != "fish" ]; then
IFS="|"
cat <<EOS
command="\$1"
if [ "\$#" -gt 0 ]; then
shift
fi

case "\$command" in
${commands[*]})
eval "\`nodenv "sh-\$command" "\$@"\`";;
*)
command nodenv "\$command" "\$@";;
esac
}
EOS
fi
23 changes: 23 additions & 0 deletions libexec/nodenv-sh-rehash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e
[ -n "$NODENV_DEBUG" ] && set -x

# Provide nodenv completions
if [ "$1" = "--complete" ]; then
exec nodenv-rehash --complete
fi

shell="$(basename "${NODENV_SHELL:-$SHELL}")"

# When nodenv shell integration is enabled, delegate to nodenv-rehash,
# then tell the shell to empty its command lookup cache.
nodenv-rehash

case "$shell" in
fish )
# no rehash support
;;
* )
echo "hash -r 2>/dev/null || true"
;;
esac
File renamed without changes.