diff --git a/index.js b/index.js index 00bd366..e3bcb25 100644 --- a/index.js +++ b/index.js @@ -7,8 +7,8 @@ var defineProps = Object.defineProperties; var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM); function Chalk(options) { - // detect mode if not set manually - this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled; + // detect level if not set manually + this.level = !options || options.level === undefined ? supportsColor.level : options.level; } // use bright blue on Windows as the normal blue color is illegible @@ -37,7 +37,7 @@ function build(_styles) { }; builder._styles = _styles; - builder.enabled = this.enabled; + builder.level = this.level; // __proto__ is used because we must return a function, but there is // no way to create a function with a different prototype. /* eslint-disable no-proto */ @@ -59,7 +59,7 @@ function applyStyle() { } } - if (!this.enabled || !str) { + if (!this.level || !str) { return str; } diff --git a/package.json b/package.json index 49b9ec5..3a50941 100644 --- a/package.json +++ b/package.json @@ -44,9 +44,9 @@ "text" ], "dependencies": { - "ansi-styles": "^2.1.0", + "ansi-styles": "^3.0.0", "escape-string-regexp": "^1.0.2", - "supports-color": "^3.1.2" + "supports-color": "^3.2.3" }, "devDependencies": { "coveralls": "^2.11.2", diff --git a/test.js b/test.js index 9dddc2f..ae92ec0 100644 --- a/test.js +++ b/test.js @@ -132,17 +132,18 @@ describe('chalk on windows', function () { }); }); -describe('chalk.enabled', function () { +describe('chalk.level', function () { it('should not output colors when manually disabled', function () { - chalk.enabled = false; + var oldLevel = chalk.level; + chalk.level = 0; assert.equal(chalk.red('foo'), 'foo'); - chalk.enabled = true; + chalk.level = oldLevel; }); }); describe('chalk.constructor', function () { it('should create a isolated context where colors can be disabled', function () { - var ctx = new chalk.constructor({enabled: false}); + var ctx = new chalk.constructor({level: 0}); assert.equal(ctx.red('foo'), 'foo'); assert.equal(chalk.red('foo'), '\u001b[31mfoo\u001b[39m'); });