chalk 2.3.0 → 2.4.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.js +3 -3
- package/index.js.flow +93 -0
- package/package.json +11 -6
- package/readme.md +13 -8
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const escapeStringRegexp = require('escape-string-regexp');
|
|
3
3
|
const ansiStyles = require('ansi-styles');
|
|
4
|
-
const
|
|
4
|
+
const stdoutColor = require('supports-color').stdout;
|
|
5
5
|
|
|
6
6
|
const template = require('./templates.js');
|
|
7
7
|
|
|
@@ -19,7 +19,7 @@ function applyOptions(obj, options) {
|
|
|
19
19
|
options = options || {};
|
|
20
20
|
|
|
21
21
|
// Detect level if not set manually
|
|
22
|
-
const scLevel =
|
|
22
|
+
const scLevel = stdoutColor ? stdoutColor.level : 0;
|
|
23
23
|
obj.level = options.level === undefined ? scLevel : options.level;
|
|
24
24
|
obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
|
|
25
25
|
}
|
|
@@ -224,5 +224,5 @@ function chalkTag(chalk, strings) {
|
|
|
224
224
|
Object.defineProperties(Chalk.prototype, styles);
|
|
225
225
|
|
|
226
226
|
module.exports = Chalk(); // eslint-disable-line new-cap
|
|
227
|
-
module.exports.supportsColor =
|
|
227
|
+
module.exports.supportsColor = stdoutColor;
|
|
228
228
|
module.exports.default = module.exports; // For TypeScript
|
package/index.js.flow
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
type TemplateStringsArray = $ReadOnlyArray<string>;
|
|
4
|
+
|
|
5
|
+
export type Level = $Values<{
|
|
6
|
+
None: 0,
|
|
7
|
+
Basic: 1,
|
|
8
|
+
Ansi256: 2,
|
|
9
|
+
TrueColor: 3
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
export type ChalkOptions = {|
|
|
13
|
+
enabled?: boolean,
|
|
14
|
+
level?: Level
|
|
15
|
+
|};
|
|
16
|
+
|
|
17
|
+
export type ColorSupport = {|
|
|
18
|
+
level: Level,
|
|
19
|
+
hasBasic: boolean,
|
|
20
|
+
has256: boolean,
|
|
21
|
+
has16m: boolean
|
|
22
|
+
|};
|
|
23
|
+
|
|
24
|
+
export interface Chalk {
|
|
25
|
+
(...text: string[]): string,
|
|
26
|
+
(text: TemplateStringsArray, ...placeholders: string[]): string,
|
|
27
|
+
constructor(options?: ChalkOptions): Chalk,
|
|
28
|
+
enabled: boolean,
|
|
29
|
+
level: Level,
|
|
30
|
+
rgb(r: number, g: number, b: number): Chalk,
|
|
31
|
+
hsl(h: number, s: number, l: number): Chalk,
|
|
32
|
+
hsv(h: number, s: number, v: number): Chalk,
|
|
33
|
+
hwb(h: number, w: number, b: number): Chalk,
|
|
34
|
+
bgHex(color: string): Chalk,
|
|
35
|
+
bgKeyword(color: string): Chalk,
|
|
36
|
+
bgRgb(r: number, g: number, b: number): Chalk,
|
|
37
|
+
bgHsl(h: number, s: number, l: number): Chalk,
|
|
38
|
+
bgHsv(h: number, s: number, v: number): Chalk,
|
|
39
|
+
bgHwb(h: number, w: number, b: number): Chalk,
|
|
40
|
+
hex(color: string): Chalk,
|
|
41
|
+
keyword(color: string): Chalk,
|
|
42
|
+
|
|
43
|
+
+reset: Chalk,
|
|
44
|
+
+bold: Chalk,
|
|
45
|
+
+dim: Chalk,
|
|
46
|
+
+italic: Chalk,
|
|
47
|
+
+underline: Chalk,
|
|
48
|
+
+inverse: Chalk,
|
|
49
|
+
+hidden: Chalk,
|
|
50
|
+
+strikethrough: Chalk,
|
|
51
|
+
|
|
52
|
+
+visible: Chalk,
|
|
53
|
+
|
|
54
|
+
+black: Chalk,
|
|
55
|
+
+red: Chalk,
|
|
56
|
+
+green: Chalk,
|
|
57
|
+
+yellow: Chalk,
|
|
58
|
+
+blue: Chalk,
|
|
59
|
+
+magenta: Chalk,
|
|
60
|
+
+cyan: Chalk,
|
|
61
|
+
+white: Chalk,
|
|
62
|
+
+gray: Chalk,
|
|
63
|
+
+grey: Chalk,
|
|
64
|
+
+blackBright: Chalk,
|
|
65
|
+
+redBright: Chalk,
|
|
66
|
+
+greenBright: Chalk,
|
|
67
|
+
+yellowBright: Chalk,
|
|
68
|
+
+blueBright: Chalk,
|
|
69
|
+
+magentaBright: Chalk,
|
|
70
|
+
+cyanBright: Chalk,
|
|
71
|
+
+whiteBright: Chalk,
|
|
72
|
+
|
|
73
|
+
+bgBlack: Chalk,
|
|
74
|
+
+bgRed: Chalk,
|
|
75
|
+
+bgGreen: Chalk,
|
|
76
|
+
+bgYellow: Chalk,
|
|
77
|
+
+bgBlue: Chalk,
|
|
78
|
+
+bgMagenta: Chalk,
|
|
79
|
+
+bgCyan: Chalk,
|
|
80
|
+
+bgWhite: Chalk,
|
|
81
|
+
+bgBlackBright: Chalk,
|
|
82
|
+
+bgRedBright: Chalk,
|
|
83
|
+
+bgGreenBright: Chalk,
|
|
84
|
+
+bgYellowBright: Chalk,
|
|
85
|
+
+bgBlueBright: Chalk,
|
|
86
|
+
+bgMagentaBright: Chalk,
|
|
87
|
+
+bgCyanBright: Chalk,
|
|
88
|
+
+bgWhiteBrigh: Chalk,
|
|
89
|
+
|
|
90
|
+
supportsColor: ColorSupport
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
declare module.exports: Chalk;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chalk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Terminal string styling done right",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/chalk",
|
|
@@ -8,14 +8,15 @@
|
|
|
8
8
|
"node": ">=4"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "xo && tsc --project types && nyc ava",
|
|
11
|
+
"test": "xo && tsc --project types && flow --max-warnings=0 && nyc ava",
|
|
12
12
|
"bench": "matcha benchmark.js",
|
|
13
13
|
"coveralls": "nyc report --reporter=text-lcov | coveralls"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"index.js",
|
|
17
17
|
"templates.js",
|
|
18
|
-
"types/index.d.ts"
|
|
18
|
+
"types/index.d.ts",
|
|
19
|
+
"index.js.flow"
|
|
19
20
|
],
|
|
20
21
|
"keywords": [
|
|
21
22
|
"color",
|
|
@@ -41,14 +42,15 @@
|
|
|
41
42
|
"text"
|
|
42
43
|
],
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"ansi-styles": "^3.1
|
|
45
|
+
"ansi-styles": "^3.2.1",
|
|
45
46
|
"escape-string-regexp": "^1.0.5",
|
|
46
|
-
"supports-color": "^
|
|
47
|
+
"supports-color": "^5.3.0"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"ava": "*",
|
|
50
51
|
"coveralls": "^3.0.0",
|
|
51
|
-
"execa": "^0.
|
|
52
|
+
"execa": "^0.9.0",
|
|
53
|
+
"flow-bin": "^0.68.0",
|
|
52
54
|
"import-fresh": "^2.0.0",
|
|
53
55
|
"matcha": "^0.7.0",
|
|
54
56
|
"nyc": "^11.0.2",
|
|
@@ -61,6 +63,9 @@
|
|
|
61
63
|
"envs": [
|
|
62
64
|
"node",
|
|
63
65
|
"mocha"
|
|
66
|
+
],
|
|
67
|
+
"ignores": [
|
|
68
|
+
"test/_flow.js"
|
|
64
69
|
]
|
|
65
70
|
}
|
|
66
71
|
}
|
package/readme.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
2
|
<br>
|
|
3
3
|
<br>
|
|
4
|
-
<img width="320" src="
|
|
4
|
+
<img width="320" src="media/logo.svg" alt="Chalk">
|
|
5
5
|
<br>
|
|
6
6
|
<br>
|
|
7
7
|
<br>
|
|
@@ -9,11 +9,11 @@
|
|
|
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.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/
|
|
12
|
+
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo) [](https://github.com/sindresorhus/awesome-nodejs)
|
|
13
13
|
|
|
14
14
|
### [See what's new in Chalk 2](https://github.com/chalk/chalk/releases/tag/v2.0.0)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
<img src="https://cdn.rawgit.com/chalk/ansi-styles/8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" alt="" width="900">
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
## Highlights
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
- Doesn't extend `String.prototype`
|
|
27
27
|
- Clean and focused
|
|
28
28
|
- Actively maintained
|
|
29
|
-
- [Used by ~
|
|
29
|
+
- [Used by ~23,000 packages](https://www.npmjs.com/browse/depended/chalk) as of December 31, 2017
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
## Install
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
$ npm install chalk
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
<a href="https://www.patreon.com/sindresorhus">
|
|
39
|
+
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
|
40
|
+
</a>
|
|
41
|
+
|
|
38
42
|
|
|
39
43
|
## Usage
|
|
40
44
|
|
|
@@ -51,7 +55,7 @@ const chalk = require('chalk');
|
|
|
51
55
|
const log = console.log;
|
|
52
56
|
|
|
53
57
|
// Combine styled and normal strings
|
|
54
|
-
log(chalk.blue('Hello') + 'World' + chalk.red('!'));
|
|
58
|
+
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
|
55
59
|
|
|
56
60
|
// Compose multiple styles using the chainable API
|
|
57
61
|
log(chalk.blue.bgRed.bold('Hello world!'));
|
|
@@ -124,7 +128,7 @@ Multiple arguments will be separated by space.
|
|
|
124
128
|
|
|
125
129
|
Color support is automatically detected, as is the level (see `chalk.level`). However, if you'd like to simply enable/disable Chalk, you can do so via the `.enabled` property.
|
|
126
130
|
|
|
127
|
-
Chalk is enabled by default unless
|
|
131
|
+
Chalk is enabled by default unless explicitly disabled via the constructor or `chalk.level` is `0`.
|
|
128
132
|
|
|
129
133
|
If you need to change this in a reusable module, create a new instance:
|
|
130
134
|
|
|
@@ -265,8 +269,8 @@ The following color models can be used:
|
|
|
265
269
|
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
|
266
270
|
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
|
267
271
|
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
|
268
|
-
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.
|
|
269
|
-
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.
|
|
272
|
+
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
|
273
|
+
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
|
270
274
|
- `ansi16`
|
|
271
275
|
- `ansi256`
|
|
272
276
|
|
|
@@ -296,6 +300,7 @@ If you're on Windows, do yourself a favor and use [`cmder`](http://cmder.net/) i
|
|
|
296
300
|
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
|
297
301
|
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
|
298
302
|
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
|
303
|
+
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
|
299
304
|
|
|
300
305
|
|
|
301
306
|
## Maintainers
|