2016-06-26 08:00:19 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-12-17 14:58:06 +08:00
|
|
|
set -e
|
2016-06-26 08:00:19 +08:00
|
|
|
|
2016-11-07 03:34:36 +08:00
|
|
|
die () { echo "$@" ; cleanup ; exit 1; }
|
2016-06-26 08:00:19 +08:00
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
unset -f nvm_download nvm_ls_remote nvm_ls_remote_iojs
|
[New] Added `set-colors` command. See details below:
This command allows users to replace default colors with their own custom colors.
- top-level commands modified: alias, ls, ls-remote
- helper functions added: nvm_echo_with_colors, nvm_err_with_colors,
nvm_set_colors, nvm_get_colors, nvm_print_color_code
- functions modified: nvm_print_formatted_alias, nvm_print_versions, nvm_print_alias_path (implicitly), nvm_print_default_alias (implicitly), nvm_list_aliases (implicitly)
We added tests and info on using this command to the README!
Co-authored-by: Dena Burd <29719099+gitburd@users.noreply.github.com>
Co-authored-by: Naomi Quinones <52065567+naomiquinones@users.noreply.github.com>
2020-08-18 05:56:13 +08:00
|
|
|
if [ -n TEMP_NVM_COLORS ]; then
|
|
|
|
export NVM_COLORS=TEMP_NVM_COLORS
|
|
|
|
fi
|
|
|
|
unset TEMP_NVM_COLORS
|
2016-06-26 08:00:19 +08:00
|
|
|
}
|
|
|
|
|
2016-11-04 13:15:18 +08:00
|
|
|
\. ../../../nvm.sh
|
[New] Added `set-colors` command. See details below:
This command allows users to replace default colors with their own custom colors.
- top-level commands modified: alias, ls, ls-remote
- helper functions added: nvm_echo_with_colors, nvm_err_with_colors,
nvm_set_colors, nvm_get_colors, nvm_print_color_code
- functions modified: nvm_print_formatted_alias, nvm_print_versions, nvm_print_alias_path (implicitly), nvm_print_default_alias (implicitly), nvm_list_aliases (implicitly)
We added tests and info on using this command to the README!
Co-authored-by: Dena Burd <29719099+gitburd@users.noreply.github.com>
Co-authored-by: Naomi Quinones <52065567+naomiquinones@users.noreply.github.com>
2020-08-18 05:56:13 +08:00
|
|
|
if [ -n ${NVM_COLORS} ]; then
|
|
|
|
export TEMP_NVM_COLORS=NVM_COLORS
|
|
|
|
unset NVM_COLORS
|
|
|
|
fi
|
2016-06-26 08:00:19 +08:00
|
|
|
|
|
|
|
nvm deactivate 2>/dev/null || die 'unable to deactivate'
|
|
|
|
|
2016-11-04 13:15:18 +08:00
|
|
|
\. ../../common.sh
|
2016-06-26 08:00:19 +08:00
|
|
|
|
|
|
|
REMOTE="$PWD/mocks/nvm_ls_remote.txt"
|
|
|
|
nvm_ls_remote() {
|
|
|
|
cat "$REMOTE"
|
|
|
|
}
|
|
|
|
REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt"
|
|
|
|
nvm_ls_remote_iojs() {
|
|
|
|
cat "$REMOTE_IOJS"
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECTED_OUTPUT_PATH="$PWD/mocks/nvm ls-remote.txt"
|
|
|
|
OUTPUT="$(nvm ls-remote | sed 's/[ \t]*$//')"
|
|
|
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm ls-remote did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
|
|
|
|
2021-12-17 14:58:06 +08:00
|
|
|
EXPECTED_OUTPUT_PATH="$PWD/mocks/nvm ls-remote lts.txt"
|
|
|
|
OUTPUT="$(nvm ls-remote --lts="*" | sed 's/[ \t]*$//')"
|
|
|
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote --lts=* did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
|
|
|
|
|
|
|
EXPECTED_OUTPUT_PATH="$PWD/mocks/nvm ls-remote lts.txt"
|
|
|
|
OUTPUT="$(nvm ls-remote "lts/*" | sed 's/[ \t]*$//')"
|
|
|
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
|
|
|
|
2016-06-26 08:00:19 +08:00
|
|
|
cleanup
|