Skip to content

Commit eeaddf9

Browse files
committed
Don’t restrict colors to TTYs.
This restriction prevents subcommands from producing colors and passing them up the tree to the actual TTY.
1 parent 0880539 commit eeaddf9

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

nvm.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ nvm_is_alias() {
3434

3535
nvm_has_colors() {
3636
local NVM_COLORS
37-
if test -t 1; then
38-
NVM_COLORS="$(tput -T "${TERM:-vt100}" colors)"
39-
fi
37+
NVM_COLORS="$(tput -T "${TERM:-vt100}" colors)"
4038
[ "${NVM_COLORS:--1}" -ge 8 ]
4139
}
4240

test/fast/Aliases/nvm_ensure_default_set

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22

3+
. ../../common.sh
4+
35
die () { echo $@ ; exit 1; }
46

57
. ../../../nvm.sh
@@ -14,5 +16,5 @@ OUTPUT="$(nvm_ensure_default_set 0.2)"
1416
EXPECTED_OUTPUT="Creating default alias: default -> 0.2 (-> iojs-v0.2.10)"
1517
EXIT_CODE="$?"
1618

17-
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set 0.2' did not output '$EXPECTED_OUTPUT', got '$OUTPUT'"
19+
[ "_$(echo "$OUTPUT" | strip_colors)" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set 0.2' did not output '$EXPECTED_OUTPUT', got '$OUTPUT'"
1820
[ "_$EXIT_CODE" = "_0" ] || die "'nvm_ensure_default_set 0.2' did not exit with 0, got $EXIT_CODE"
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/bin/sh
22

3+
. ../../common.sh
4+
35
die () { echo $@ ; exit 1; }
46

57
. ../../../nvm.sh
68

79
EXPECTED_OUTPUT="nvm_ensure_default_set: a version is required"
810
OUTPUT="$(nvm_ensure_default_set 2>&1 >/dev/null)"
911
EXIT_CODE="$?"
10-
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set' did not output "$EXPECTED_OUTPUT", got "$OUTPUT""
12+
[ "_$(echo "$OUTPUT" | strip_colors)" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set' did not output "$EXPECTED_OUTPUT", got "$OUTPUT""
1113
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_ensure_default_set' did not exit with 1, got "$EXIT_CODE""
1214

1315
# see test/fast/Aliases for remaining nvm_ensure_default_set tests

0 commit comments

Comments
 (0)