-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
env.sh
executable file
·51 lines (43 loc) · 2.19 KB
/
env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
code=0
fail() {
printf "\x1b[31m[FAIL]\x1b[39m %s\n" "$@" >&2
code=1
}
colors() {
printf "\x1b[33m[DEBUG]\x1b[39m \"%s\" :: %s \n" "$2" "$1"
[ "$1" != "foo" ] || fail "$2"
}
nocolor() {
printf "\x1b[33m[DEBUG]\x1b[39m \"%s\" :: %s \n" "$2" "$1"
[[ "$1" =~ foo* ]] || fail "$2"
}
faketty() {
script -qfc "$(printf "%q " "$@")" /dev/null
}
# process.stdout.isTTY = undefined;
printf "\nprocess.stdout.isTTY = %s;\n" `node -p "process.stdout.isTTY"`
nocolor `node -p "require('.').red('foo')"` "FORCE_COLOR=?"
nocolor `FORCE_COLOR=0 node -p "require('.').red('foo')"` "FORCE_COLOR=0"
nocolor `NODE_DISABLE_COLORS=1 node -p "require('.').red('foo')"` "NODE_DISABLE_COLORS=1"
nocolor `NODE_DISABLE_COLORS=1 FORCE_COLOR=1 node -p "require('.').red('foo')"` "NODE_DISABLE_COLORS=1; FORCE_COLOR=1"
nocolor `NO_COLOR=1 node -p "require('.').red('foo')"` "NO_COLOR=1"
nocolor `NO_COLOR=1 FORCE_COLOR=1 node -p "require('.').red('foo')"` "NO_COLOR=1; FORCE_COLOR=1"
colors `FORCE_COLOR=1 node -p "require('.').red('foo')"` "FORCE_COLOR=1"
nocolor `TERM=dumb FORCE_COLOR=1 node -p "require('.').red('foo')"` "TERM=dumb; FORCE_COLOR=1"
nocolor `TERM=dumb node -p "require('.').red('foo')"` "TERM=dumb"
# process.stdout.isTTY = true;
printf "\n(faketty) process.stdout.isTTY = %s;\n" `faketty node -p "process.stdout.isTTY"`
colors `faketty node -p "require('.').red('foo')"` "FORCE_COLOR=?"
colors `FORCE_COLOR=0 faketty node -p "require('.').red('foo')"` "FORCE_COLOR=0"
nocolor `NODE_DISABLE_COLORS=1 faketty node -p "require('.').red('foo')"` "NODE_DISABLE_COLORS=1"
nocolor `NODE_DISABLE_COLORS=1 FORCE_COLOR=1 faketty node -p "require('.').red('foo')"` "NODE_DISABLE_COLORS=1; FORCE_COLOR=1"
nocolor `NO_COLOR=1 faketty node -p "require('.').red('foo')"` "NO_COLOR=1"
nocolor `NO_COLOR=1 FORCE_COLOR=1 faketty node -p "require('.').red('foo')"` "NO_COLOR=1; FORCE_COLOR=1"
nocolor `TERM=dumb FORCE_COLOR=1 faketty node -p "require('.').red('foo')"` "TERM=dumb; FORCE_COLOR=1"
colors `FORCE_COLOR=1 faketty node -p "require('.').red('foo')"` "FORCE_COLOR=1"
nocolor `TERM=dumb node -r esm test/xyz.js` "TERM=dumb"
if [ "$code" == "0" ]; then
printf "\x1b[32m[PASS]\x1b[39m $.enabled updates correctly \n"
fi
exit $code