HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/ubuntu/.nvm/test/fast/Running 'nvm use system' should work as expected
#!/bin/sh

set -eux

cleanup() {
  unset -f nvm_has_system_node nvm_print_npm_version
}
die() { echo "$@" ; cleanup ; exit 1; }

\. ../../nvm.sh

nvm_has_system_node() { return 0; }
nvm_print_npm_version() { command printf ' (npm v1.2.3)'; }

EXPECTED_OUTPUT="Now using system version of node: $(node -v)$(nvm_print_npm_version)"
set +x # since stderr is needed
OUTPUT="$(nvm use system 2>&1)"
set -x
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "Could not use system version of node. Got >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<"

EXPECTED_OUTPUT=""
set +x # since stderr is needed
OUTPUT="$(nvm use --silent system 2>&1 | tail -1)"
set -x
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "Could not use system version of node or --silent was not silent"

nvm_has_system_node() { return 1; }
nvm_print_npm_version() { command printf ''; }

EXPECTED_OUTPUT="System version of node not found."
set +x # since stderr is needed
OUTPUT="$(nvm use system 2>&1 | tail -1)"
set -x
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "Did not report error, system node not found"

nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"
EXPECTED_OUTPUT=""
set +x # since stderr is needed
OUTPUT="$(nvm use --silent system 2>&1 | tail -1)"
set -x
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "Did not report error, system node not found or --silent was not silent"
nvm use --silent system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found or --silent was not silent"

cleanup