chalk 3.0.0-beta.2 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +51 -30
- package/package.json +12 -7
- package/readme.md +51 -28
- package/source/index.js +12 -16
- package/source/templates.js +3 -3
package/index.d.ts
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
declare const enum LevelEnum {
|
|
2
|
-
/**
|
|
3
|
-
All colors disabled.
|
|
4
|
-
*/
|
|
5
|
-
None = 0,
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
Basic 16 colors support.
|
|
9
|
-
*/
|
|
10
|
-
Basic = 1,
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
ANSI 256 colors support.
|
|
14
|
-
*/
|
|
15
|
-
Ansi256 = 2,
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
Truecolor 16 million colors support.
|
|
19
|
-
*/
|
|
20
|
-
TrueColor = 3
|
|
21
|
-
}
|
|
22
|
-
|
|
23
1
|
/**
|
|
24
2
|
Basic foreground colors.
|
|
25
3
|
|
|
@@ -89,22 +67,34 @@ declare type Modifiers =
|
|
|
89
67
|
| 'visible';
|
|
90
68
|
|
|
91
69
|
declare namespace chalk {
|
|
92
|
-
|
|
70
|
+
/**
|
|
71
|
+
Levels:
|
|
72
|
+
- `0` - All colors disabled.
|
|
73
|
+
- `1` - Basic 16 colors support.
|
|
74
|
+
- `2` - ANSI 256 colors support.
|
|
75
|
+
- `3` - Truecolor 16 million colors support.
|
|
76
|
+
*/
|
|
77
|
+
type Level = 0 | 1 | 2 | 3;
|
|
93
78
|
|
|
94
79
|
interface Options {
|
|
95
80
|
/**
|
|
96
81
|
Specify the color support for Chalk.
|
|
82
|
+
|
|
97
83
|
By default, color support is automatically detected based on the environment.
|
|
84
|
+
|
|
85
|
+
Levels:
|
|
86
|
+
- `0` - All colors disabled.
|
|
87
|
+
- `1` - Basic 16 colors support.
|
|
88
|
+
- `2` - ANSI 256 colors support.
|
|
89
|
+
- `3` - Truecolor 16 million colors support.
|
|
98
90
|
*/
|
|
99
91
|
level?: Level;
|
|
100
92
|
}
|
|
101
93
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
new (options?: Options): Chalk;
|
|
107
|
-
}
|
|
94
|
+
/**
|
|
95
|
+
Return a new Chalk instance.
|
|
96
|
+
*/
|
|
97
|
+
type Instance = new (options?: Options) => Chalk;
|
|
108
98
|
|
|
109
99
|
/**
|
|
110
100
|
Detect whether the terminal supports color.
|
|
@@ -147,6 +137,13 @@ declare namespace chalk {
|
|
|
147
137
|
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
|
148
138
|
`);
|
|
149
139
|
```
|
|
140
|
+
|
|
141
|
+
@example
|
|
142
|
+
```
|
|
143
|
+
import chalk = require('chalk');
|
|
144
|
+
|
|
145
|
+
log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
|
|
146
|
+
```
|
|
150
147
|
*/
|
|
151
148
|
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
|
152
149
|
|
|
@@ -161,7 +158,14 @@ declare namespace chalk {
|
|
|
161
158
|
|
|
162
159
|
/**
|
|
163
160
|
The color support for Chalk.
|
|
161
|
+
|
|
164
162
|
By default, color support is automatically detected based on the environment.
|
|
163
|
+
|
|
164
|
+
Levels:
|
|
165
|
+
- `0` - All colors disabled.
|
|
166
|
+
- `1` - Basic 16 colors support.
|
|
167
|
+
- `2` - ANSI 256 colors support.
|
|
168
|
+
- `3` - Truecolor 16 million colors support.
|
|
165
169
|
*/
|
|
166
170
|
level: Level;
|
|
167
171
|
|
|
@@ -213,6 +217,14 @@ declare namespace chalk {
|
|
|
213
217
|
*/
|
|
214
218
|
hwb(hue: number, whiteness: number, blackness: number): Chalk;
|
|
215
219
|
|
|
220
|
+
/**
|
|
221
|
+
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
|
|
222
|
+
|
|
223
|
+
30 <= code && code < 38 || 90 <= code && code < 98
|
|
224
|
+
For example, 31 for red, 91 for redBright.
|
|
225
|
+
*/
|
|
226
|
+
ansi(code: number): Chalk;
|
|
227
|
+
|
|
216
228
|
/**
|
|
217
229
|
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
|
218
230
|
*/
|
|
@@ -266,6 +278,15 @@ declare namespace chalk {
|
|
|
266
278
|
*/
|
|
267
279
|
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
|
|
268
280
|
|
|
281
|
+
/**
|
|
282
|
+
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
|
|
283
|
+
|
|
284
|
+
30 <= code && code < 38 || 90 <= code && code < 98
|
|
285
|
+
For example, 31 for red, 91 for redBright.
|
|
286
|
+
Use the foreground code, not the background code (for example, not 41, nor 101).
|
|
287
|
+
*/
|
|
288
|
+
bgAnsi(code: number): Chalk;
|
|
289
|
+
|
|
269
290
|
/**
|
|
270
291
|
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
|
271
292
|
*/
|
|
@@ -383,7 +404,7 @@ This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
|
|
383
404
|
*/
|
|
384
405
|
declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
|
385
406
|
supportsColor: chalk.ColorSupport | false;
|
|
386
|
-
Level:
|
|
407
|
+
Level: chalk.Level;
|
|
387
408
|
Color: Color;
|
|
388
409
|
ForegroundColor: ForegroundColor;
|
|
389
410
|
BackgroundColor: BackgroundColor;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chalk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Terminal string styling done right",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/chalk",
|
|
7
|
+
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
|
7
8
|
"main": "source",
|
|
8
9
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
10
|
+
"node": ">=10"
|
|
10
11
|
},
|
|
11
12
|
"scripts": {
|
|
12
13
|
"test": "xo && nyc ava && tsd",
|
|
@@ -45,19 +46,23 @@
|
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"ava": "^2.4.0",
|
|
48
|
-
"coveralls": "^3.0.
|
|
49
|
-
"execa": "^
|
|
49
|
+
"coveralls": "^3.0.7",
|
|
50
|
+
"execa": "^4.0.0",
|
|
50
51
|
"import-fresh": "^3.1.0",
|
|
51
52
|
"matcha": "^0.7.0",
|
|
52
|
-
"nyc": "^
|
|
53
|
+
"nyc": "^15.0.0",
|
|
53
54
|
"resolve-from": "^5.0.0",
|
|
54
55
|
"tsd": "^0.7.4",
|
|
55
|
-
"xo": "^0.
|
|
56
|
+
"xo": "^0.28.2"
|
|
56
57
|
},
|
|
57
58
|
"xo": {
|
|
58
59
|
"rules": {
|
|
59
60
|
"unicorn/prefer-string-slice": "off",
|
|
60
|
-
"unicorn/prefer-includes": "off"
|
|
61
|
+
"unicorn/prefer-includes": "off",
|
|
62
|
+
"@typescript-eslint/member-ordering": "off",
|
|
63
|
+
"no-redeclare": "off",
|
|
64
|
+
"unicorn/string-content": "off",
|
|
65
|
+
"unicorn/better-regex": "off"
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
}
|
package/readme.md
CHANGED
|
@@ -9,12 +9,51 @@
|
|
|
9
9
|
|
|
10
10
|
> Terminal string styling done right
|
|
11
11
|
|
|
12
|
-
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo) 
|
|
12
|
+
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo)  [](https://repl.it/github/chalk/chalk)
|
|
13
13
|
|
|
14
14
|
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
<br>
|
|
17
17
|
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
<div align="center">
|
|
21
|
+
<p>
|
|
22
|
+
<p>
|
|
23
|
+
<sup>
|
|
24
|
+
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a> and <a href="https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15">Dev</a>
|
|
25
|
+
</sup>
|
|
26
|
+
</p>
|
|
27
|
+
<sup>Special thanks to:</sup>
|
|
28
|
+
<br>
|
|
29
|
+
<br>
|
|
30
|
+
<a href="https://standardresume.co/tech">
|
|
31
|
+
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160"/>
|
|
32
|
+
</a>
|
|
33
|
+
<br>
|
|
34
|
+
<br>
|
|
35
|
+
<a href="https://retool.com/?utm_campaign=sindresorhus">
|
|
36
|
+
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="210"/>
|
|
37
|
+
</a>
|
|
38
|
+
<br>
|
|
39
|
+
<br>
|
|
40
|
+
<a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
|
|
41
|
+
<div>
|
|
42
|
+
<img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
|
|
43
|
+
</div>
|
|
44
|
+
<b>All your environment variables, in one place</b>
|
|
45
|
+
<div>
|
|
46
|
+
<span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
|
|
47
|
+
<br>
|
|
48
|
+
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
|
|
49
|
+
</div>
|
|
50
|
+
</a>
|
|
51
|
+
</p>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
<br>
|
|
18
57
|
|
|
19
58
|
## Highlights
|
|
20
59
|
|
|
@@ -26,8 +65,7 @@
|
|
|
26
65
|
- Doesn't extend `String.prototype`
|
|
27
66
|
- Clean and focused
|
|
28
67
|
- Actively maintained
|
|
29
|
-
- [Used by ~
|
|
30
|
-
|
|
68
|
+
- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020
|
|
31
69
|
|
|
32
70
|
## Install
|
|
33
71
|
|
|
@@ -35,7 +73,6 @@
|
|
|
35
73
|
$ npm install chalk
|
|
36
74
|
```
|
|
37
75
|
|
|
38
|
-
|
|
39
76
|
## Usage
|
|
40
77
|
|
|
41
78
|
```js
|
|
@@ -109,7 +146,6 @@ console.log(chalk.green('Hello %s'), name);
|
|
|
109
146
|
//=> 'Hello Sindre'
|
|
110
147
|
```
|
|
111
148
|
|
|
112
|
-
|
|
113
149
|
## API
|
|
114
150
|
|
|
115
151
|
### chalk.`<style>[.<style>...](string, [string...])`
|
|
@@ -151,7 +187,6 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
|
|
151
187
|
|
|
152
188
|
`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
|
|
153
189
|
|
|
154
|
-
|
|
155
190
|
## Styles
|
|
156
191
|
|
|
157
192
|
### Modifiers
|
|
@@ -204,10 +239,9 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
|
|
204
239
|
- `bgCyanBright`
|
|
205
240
|
- `bgWhiteBright`
|
|
206
241
|
|
|
207
|
-
|
|
208
242
|
## Tagged template literal
|
|
209
243
|
|
|
210
|
-
Chalk can be used as a [tagged template literal](
|
|
244
|
+
Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
|
211
245
|
|
|
212
246
|
```js
|
|
213
247
|
const chalk = require('chalk');
|
|
@@ -223,10 +257,11 @@ console.log(chalk`
|
|
|
223
257
|
|
|
224
258
|
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
|
225
259
|
|
|
226
|
-
Template styles are chained exactly like normal Chalk styles. The following
|
|
260
|
+
Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
|
|
227
261
|
|
|
228
262
|
```js
|
|
229
263
|
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
|
264
|
+
console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
|
|
230
265
|
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
|
231
266
|
```
|
|
232
267
|
|
|
@@ -234,7 +269,6 @@ Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain
|
|
|
234
269
|
|
|
235
270
|
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
|
236
271
|
|
|
237
|
-
|
|
238
272
|
## 256 and Truecolor color support
|
|
239
273
|
|
|
240
274
|
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
|
@@ -261,19 +295,22 @@ The following color models can be used:
|
|
|
261
295
|
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
|
262
296
|
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
|
263
297
|
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
|
264
|
-
- `
|
|
298
|
+
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
|
|
265
299
|
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
|
266
300
|
|
|
267
|
-
|
|
268
301
|
## Windows
|
|
269
302
|
|
|
270
303
|
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
|
271
304
|
|
|
272
|
-
|
|
273
305
|
## Origin story
|
|
274
306
|
|
|
275
307
|
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
|
|
276
308
|
|
|
309
|
+
## chalk for enterprise
|
|
310
|
+
|
|
311
|
+
Available as part of the Tidelift Subscription.
|
|
312
|
+
|
|
313
|
+
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
|
277
314
|
|
|
278
315
|
## Related
|
|
279
316
|
|
|
@@ -292,21 +329,7 @@ If you're on Windows, do yourself a favor and use [Windows Terminal](https://git
|
|
|
292
329
|
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
|
293
330
|
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
|
294
331
|
|
|
295
|
-
|
|
296
332
|
## Maintainers
|
|
297
333
|
|
|
298
334
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
|
299
335
|
- [Josh Junon](https://github.com/qix-)
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
<div align="center">
|
|
305
|
-
<b>
|
|
306
|
-
<a href="https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=readme">Get professional support for Chalk with a Tidelift subscription</a>
|
|
307
|
-
</b>
|
|
308
|
-
<br>
|
|
309
|
-
<sub>
|
|
310
|
-
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
|
311
|
-
</sub>
|
|
312
|
-
</div>
|
package/source/index.js
CHANGED
|
@@ -6,6 +6,8 @@ const {
|
|
|
6
6
|
stringEncaseCRLFWithFirstIndex
|
|
7
7
|
} = require('./util');
|
|
8
8
|
|
|
9
|
+
const {isArray} = Array;
|
|
10
|
+
|
|
9
11
|
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
|
10
12
|
const levelMapping = [
|
|
11
13
|
'ansi',
|
|
@@ -17,7 +19,7 @@ const levelMapping = [
|
|
|
17
19
|
const styles = Object.create(null);
|
|
18
20
|
|
|
19
21
|
const applyOptions = (object, options = {}) => {
|
|
20
|
-
if (options.level
|
|
22
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
21
23
|
throw new Error('The `level` option should be an integer from 0 to 3');
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -28,6 +30,7 @@ const applyOptions = (object, options = {}) => {
|
|
|
28
30
|
|
|
29
31
|
class ChalkClass {
|
|
30
32
|
constructor(options) {
|
|
33
|
+
// eslint-disable-next-line no-constructor-return
|
|
31
34
|
return chalkFactory(options);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
@@ -134,14 +137,19 @@ const createStyler = (open, close, parent) => {
|
|
|
134
137
|
|
|
135
138
|
const createBuilder = (self, _styler, _isEmpty) => {
|
|
136
139
|
const builder = (...arguments_) => {
|
|
140
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
141
|
+
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
|
|
142
|
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
143
|
+
}
|
|
144
|
+
|
|
137
145
|
// Single argument is hot path, implicit coercion is faster than anything
|
|
138
146
|
// eslint-disable-next-line no-implicit-coercion
|
|
139
147
|
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
|
140
148
|
};
|
|
141
149
|
|
|
142
|
-
//
|
|
150
|
+
// We alter the prototype because we must return a function, but there is
|
|
143
151
|
// no way to create a function with a different prototype
|
|
144
|
-
builder
|
|
152
|
+
Object.setPrototypeOf(builder, proto);
|
|
145
153
|
|
|
146
154
|
builder._generator = self;
|
|
147
155
|
builder._styler = _styler;
|
|
@@ -188,7 +196,7 @@ let template;
|
|
|
188
196
|
const chalkTag = (chalk, ...strings) => {
|
|
189
197
|
const [firstString] = strings;
|
|
190
198
|
|
|
191
|
-
if (!
|
|
199
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
192
200
|
// If chalk() was called by itself or with a string,
|
|
193
201
|
// return the string itself as a string.
|
|
194
202
|
return strings.join(' ');
|
|
@@ -218,16 +226,4 @@ chalk.supportsColor = stdoutColor;
|
|
|
218
226
|
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
|
219
227
|
chalk.stderr.supportsColor = stderrColor;
|
|
220
228
|
|
|
221
|
-
// For TypeScript
|
|
222
|
-
chalk.Level = {
|
|
223
|
-
None: 0,
|
|
224
|
-
Basic: 1,
|
|
225
|
-
Ansi256: 2,
|
|
226
|
-
TrueColor: 3,
|
|
227
|
-
0: 'None',
|
|
228
|
-
1: 'Basic',
|
|
229
|
-
2: 'Ansi256',
|
|
230
|
-
3: 'TrueColor'
|
|
231
|
-
};
|
|
232
|
-
|
|
233
229
|
module.exports = chalk;
|
package/source/templates.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
|
3
3
|
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
4
4
|
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
5
|
-
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}
|
|
5
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
6
6
|
|
|
7
7
|
const ESCAPES = new Map([
|
|
8
8
|
['n', '\n'],
|
|
@@ -126,8 +126,8 @@ module.exports = (chalk, temporary) => {
|
|
|
126
126
|
chunks.push(chunk.join(''));
|
|
127
127
|
|
|
128
128
|
if (styles.length > 0) {
|
|
129
|
-
const
|
|
130
|
-
throw new Error(
|
|
129
|
+
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
|
130
|
+
throw new Error(errMessage);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
return chunks.join('');
|