Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 24, 2024
1 parent 0ce8f5a commit e77b543
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2922,11 +2922,11 @@ nvm_is_natural_num() {

nvm_write_nvmrc() {
local VERSION_STRING
VERSION_STRING=$(nvm_version "${1-$VERSION_STRING}")
if [ "$VERSION_STRING" = '' ] || [ "$VERSION_STRING" = 'N/A' ]; then
VERSION_STRING=$(nvm_version "${1-}")
if [ "${VERSION_STRING}" = '' ] || [ "${VERSION_STRING}" = 'N/A' ]; then
return 1
fi
echo "$VERSION_STRING" | tee "$PWD"/.nvmrc > /dev/null || {
echo "${VERSION_STRING}" | tee "$PWD"/.nvmrc > /dev/null || {
if [ "${NVM_SILENT:-0}" -ne 1 ]; then
nvm_err "Warning: Unable to write version number ($VERSION_STRING) to .nvmrc"
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,42 @@

set -e

TEST_VERSION="v0.2.4"
TEST_VERSION='v0.2.4'

if [ -f .nvmrc ]; then mv .nvmrc .nvmrc.orig; fi

cleanup () {
cleanup() {
nvm cache clear
nvm deactivate
nvm unalias default
rm -rf ${NVM_DIR}/v* .nvmrc
rm -rf "${NVM_DIR}/v0.2.4" .nvmrc
if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi
unset -f nvm_ls_remote nvm_ls_remote_iojs
}

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

REMOTE="$PWD/mocks/nvm_ls_remote.txt"
REMOTE="${PWD}/mocks/nvm_ls_remote.txt"
nvm_ls_remote() {
cat "$REMOTE"
cat "${REMOTE}"
}
REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt"
nvm_ls_remote_iojs() {
cat "$REMOTE_IOJS"
cat "${REMOTE_IOJS}"
}

make_fake_node "$TEST_VERSION"
echo "|$PWD|$NVM_DIR|"

nvm install --save "$TEST_VERSION" || die "\`nvm install --save $TEST_VERSION\` failed"
make_fake_node "${TEST_VERSION}"

nvm install --save "${TEST_VERSION}" || die "\`nvm install --save ${TEST_VERSION}\` failed"
OUTPUT="$(cat .nvmrc)"

nvm_is_valid_version "$(cat .nvmrc)" \
|| die "\`nvm install --save $TEST_VERSION\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'"
|| die "\`nvm install --save ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'"

cleanup

0 comments on commit e77b543

Please sign in to comment.