Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4088,6 +4088,10 @@ nvm() {
local NVM_NO_COLORS
local NVM_NO_ALIAS

if ! command tty -s <&1; then
command set -- "$@" "--no-colors"
fi

while [ $# -gt 0 ]; do
case "${1}" in
--) ;;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

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

\. ../../../nvm.sh
\. ../../common.sh

make_fake_node v0.0.1

output=$(nvm ls | cat)

if printf '%s' "$output" | grep -Eq '\x1b\[[0-9;]*m'; then
die "FAIL: nvm ls printed colors when piped"
exit 1
else
echo "PASS: no colors when piped"
fi
Loading