Skip to content
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

Allow global installation of NVM with individual user .nvm directories for Node installs #3056

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion nvm-exec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be considered a breaking change if someone's relying on the lack of realpath here, wrt symlinks?


unset NVM_CD_FLAGS

Expand Down
8 changes: 7 additions & 1 deletion nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4075,8 +4075,14 @@ nvm() {
nvm_echo "Running node ${VERSION}$(nvm use --silent "${VERSION}" && nvm_print_npm_version)"
fi
fi
NODE_VERSION="${VERSION}" "${NVM_DIR}/nvm-exec" "$@"

NVM_EXEC="${NVM_DIR}/nvm-exec"
if [ ! -f "${NVM_EXEC}" ]; then
NVM_EXEC="$(dirname "${BASH_SOURCE[0]-}")/nvm-exec"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this needs to be reworked given 19f452b / #3499.

fi
NODE_VERSION="${VERSION}" "${NVM_EXEC}" "$@"
;;

"ls" | "list")
local PATTERN
local NVM_NO_COLORS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -ex

die () { echo "$@" ; exit 1; }

INSTPATH="$(mktemp -p "$(pwd)" -d)"
trap 'test ! -z "${INSTPATH-}" && test -d "$INSTPATH" && rm -rf "$INSTPATH"' EXIT
declare -x NVM_DIR=$INSTPATH
\. ../../../nvm.sh

nvm install --lts || die 'nvm install --lts failed'
nvm exec --lts npm --version || die "`nvm exec` failed to run"
declare -x NODE_VERSION="$(nvm exec --lts --silent node --version)"

ln -s ../../../../nvm-exec "$INSTPATH/nvm-exec" || die "failed to create a symlink to $INSTPATH/"
"$INSTPATH/nvm-exec" npm ls > /dev/null || die "`nvm exec` failed to run using nvm-exec helper"

Loading