chalk 2.2.0 → 2.2.2

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 CHANGED
@@ -58,11 +58,17 @@ for (const key of Object.keys(ansiStyles)) {
58
58
  styles[key] = {
59
59
  get() {
60
60
  const codes = ansiStyles[key];
61
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], key);
61
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
62
62
  }
63
63
  };
64
64
  }
65
65
 
66
+ styles.visible = {
67
+ get() {
68
+ return build.call(this, this._styles || [], true, 'visible');
69
+ }
70
+ };
71
+
66
72
  ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
67
73
  for (const model of Object.keys(ansiStyles.color.ansi)) {
68
74
  if (skipModels.has(model)) {
@@ -79,7 +85,7 @@ for (const model of Object.keys(ansiStyles.color.ansi)) {
79
85
  close: ansiStyles.color.close,
80
86
  closeRe: ansiStyles.color.closeRe
81
87
  };
82
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
88
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
83
89
  };
84
90
  }
85
91
  };
@@ -102,7 +108,7 @@ for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
102
108
  close: ansiStyles.bgColor.close,
103
109
  closeRe: ansiStyles.bgColor.closeRe
104
110
  };
105
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
111
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
106
112
  };
107
113
  }
108
114
  };
@@ -110,12 +116,13 @@ for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
110
116
 
111
117
  const proto = Object.defineProperties(() => {}, styles);
112
118
 
113
- function build(_styles, key) {
119
+ function build(_styles, _empty, key) {
114
120
  const builder = function () {
115
121
  return applyStyle.apply(builder, arguments);
116
122
  };
117
123
 
118
124
  builder._styles = _styles;
125
+ builder._empty = _empty;
119
126
 
120
127
  const self = this;
121
128
 
@@ -167,7 +174,7 @@ function applyStyle() {
167
174
  }
168
175
 
169
176
  if (!this.enabled || this.level <= 0 || !str) {
170
- return str;
177
+ return this._empty ? '' : str;
171
178
  }
172
179
 
173
180
  // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chalk",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Terminal string styling done right",
5
5
  "license": "MIT",
6
6
  "repository": "chalk/chalk",
package/readme.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  > Terminal string styling done right
11
11
 
12
- [![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
12
+ [![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) [![Mentioned in Awesome Node.js](https://awesome.re/mentioned-badge.svg)](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
 
@@ -170,6 +170,7 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
170
170
  - `inverse`
171
171
  - `hidden`
172
172
  - `strikethrough` *(Not widely supported)*
173
+ - `visible` (Text is emitted only if enabled)
173
174
 
174
175
  ### Colors
175
176
 
package/types/index.d.ts CHANGED
@@ -49,6 +49,8 @@ export interface Chalk {
49
49
  hidden: Chalk;
50
50
  strikethrough: Chalk;
51
51
 
52
+ visible: Chalk;
53
+
52
54
  black: Chalk;
53
55
  red: Chalk;
54
56
  green: Chalk;