aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ava/node_modules/chalk/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/ava/node_modules/chalk/index.js')
-rw-r--r--node_modules/ava/node_modules/chalk/index.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/node_modules/ava/node_modules/chalk/index.js b/node_modules/ava/node_modules/chalk/index.js
index 4c81d6d20..05e62b346 100644
--- a/node_modules/ava/node_modules/chalk/index.js
+++ b/node_modules/ava/node_modules/chalk/index.js
@@ -58,11 +58,17 @@ for (const key of Object.keys(ansiStyles)) {
styles[key] = {
get() {
const codes = ansiStyles[key];
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], key);
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
}
};
}
+styles.visible = {
+ get() {
+ return build.call(this, this._styles || [], true, 'visible');
+ }
+};
+
ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
for (const model of Object.keys(ansiStyles.color.ansi)) {
if (skipModels.has(model)) {
@@ -79,7 +85,7 @@ for (const model of Object.keys(ansiStyles.color.ansi)) {
close: ansiStyles.color.close,
closeRe: ansiStyles.color.closeRe
};
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
};
}
};
@@ -102,7 +108,7 @@ for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
close: ansiStyles.bgColor.close,
closeRe: ansiStyles.bgColor.closeRe
};
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
};
}
};
@@ -110,12 +116,13 @@ for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
const proto = Object.defineProperties(() => {}, styles);
-function build(_styles, key) {
+function build(_styles, _empty, key) {
const builder = function () {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
+ builder._empty = _empty;
const self = this;
@@ -167,7 +174,7 @@ function applyStyle() {
}
if (!this.enabled || this.level <= 0 || !str) {
- return str;
+ return this._empty ? '' : str;
}
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
@@ -218,3 +225,4 @@ Object.defineProperties(Chalk.prototype, styles);
module.exports = Chalk(); // eslint-disable-line new-cap
module.exports.supportsColor = supportsColor;
+module.exports.default = module.exports; // For TypeScript