mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-10-30 09:18:59 +08:00
[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>
This commit is contained in:
committed by
Jordan Harband
parent
3abb98124e
commit
6848c16d53
25
test/fast/Aliases/nvm_list_aliases calls nvm_get_colors
Executable file
25
test/fast/Aliases/nvm_list_aliases calls nvm_get_colors
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
echo "nvm_list_aliases did not call nvm_get_colors. Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
nvm_get_colors(){
|
||||
echo "0;95m"
|
||||
}
|
||||
|
||||
nvm_alias_path() {
|
||||
nvm_echo "../../../alias"
|
||||
}
|
||||
|
||||
OUTPUT=$(command printf %b $(nvm_list_aliases test-stable-1) | awk '{ print substr($0, 1, 19); }')
|
||||
|
||||
EXPECTED_OUTPUT=$(command printf %b "\033[0;95mtest-stable-1" | awk '{ print substr($0, 1, 19); }')
|
||||
echo "\033[0m"
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
28
test/fast/Aliases/nvm_print_alias_path calls nvm_get_colors
Executable file
28
test/fast/Aliases/nvm_print_alias_path calls nvm_get_colors
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
# echo "$@" ;
|
||||
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
nvm_get_colors(){
|
||||
echo "0;95m"
|
||||
}
|
||||
|
||||
# nvm_print_alias_path call nvm_print_formatted_alias which calls nvm_get-colors
|
||||
# the output of nvm_print_alias_path uses the color code returned by nvm_get_colors (redefined above)
|
||||
NVM_ALIAS_DIR='../../../alias'
|
||||
|
||||
OUTPUT=$(command printf %b $(nvm_print_alias_path "$NVM_ALIAS_DIR" "$NVM_ALIAS_DIR"/test-stable-1) | awk '{ print substr($0, 1, 24); }')
|
||||
|
||||
EXPECTED_OUTPUT=$(command printf %b "\033[0;95mtest-stable-1\033[0m")
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
|
||||
set +e
|
||||
21
test/fast/Aliases/nvm_print_formatted_alias calls nvm_get_colors
Executable file
21
test/fast/Aliases/nvm_print_formatted_alias calls nvm_get_colors
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
# # # expecting in red and two grays:
|
||||
OUTPUT=$(echo $(nvm_print_formatted_alias fakealias fakedest) | awk '{ print substr($0, 1, 21); }')
|
||||
EXPECTED_OUTPUT="$(command printf %b "\033[0;31mfakealias\033[0m ")"
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
|
||||
# expecting in bold yellow and two grays:
|
||||
nvm set-colors bbbYb
|
||||
OUTPUT=$(echo $(nvm_print_formatted_alias fakealias fakedest) | awk '{ print substr($0, 1, 21); }')
|
||||
EXPECTED_OUTPUT="$(command printf %b "\033[1;33mfakealias\033[0m ")"
|
||||
|
||||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
|
||||
Reference in New Issue
Block a user