-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.ts
129 lines (127 loc) · 2.63 KB
/
node.ts
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import chalk from 'chalk'
export type Tint = {
bold?: boolean
tone?: string
backTone?: string
line?: boolean
}
export default function make(text: string, tint: Tint) {
let link = chalk
if (tint.bold) {
link = link.bold
}
if (tint.line) {
link = link.underline
}
if (tint.backTone) {
switch (tint.backTone) {
case 'black':
link = link.bgBlack
break
case 'red':
link = link.bgRed
break
case 'green':
link = link.bgGreen
break
case 'yellow':
link = link.bgYellow
break
case 'blue':
link = link.bgBlue
break
case 'magenta':
link = link.bgMagenta
break
case 'cyan':
link = link.bgCyan
break
case 'white':
link = link.bgWhite
break
case 'blackBright':
link = link.bgBlackBright
break
case 'redBright':
link = link.bgRedBright
break
case 'greenBright':
link = link.bgGreenBright
break
case 'yellowBright':
link = link.bgYellowBright
break
case 'blueBright':
link = link.bgBlueBright
break
case 'magentaBright':
link = link.bgMagentaBright
break
case 'cyanBright':
link = link.bgCyanBright
break
case 'whiteBright':
link = link.bgWhiteBright
break
default:
link = link.bgHex(tint.backTone)
break
}
}
if (tint.tone) {
switch (tint.tone) {
case 'black':
link = link.black
break
case 'red':
link = link.red
break
case 'green':
link = link.green
break
case 'yellow':
link = link.yellow
break
case 'blue':
link = link.blue
break
case 'magenta':
link = link.magenta
break
case 'cyan':
link = link.cyan
break
case 'white':
link = link.white
break
case 'blackBright':
link = link.blackBright
break
case 'redBright':
link = link.redBright
break
case 'greenBright':
link = link.greenBright
break
case 'yellowBright':
link = link.yellowBright
break
case 'blueBright':
link = link.blueBright
break
case 'magentaBright':
link = link.magentaBright
break
case 'cyanBright':
link = link.cyanBright
break
case 'whiteBright':
link = link.whiteBright
break
default:
link = link.hex(tint.tone)
break
}
}
return link(text)
}