From 879defda72b072597cd4b68f6f99a4f6f6e4e67b Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 8 Dec 2013 01:02:35 +0100 Subject: [PATCH] Update to latest `ansi-styles` --- chalk.js | 2 +- package.json | 4 ++-- readme.md | 9 ++++----- test.js | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/chalk.js b/chalk.js index c4d4733..c2b9428 100644 --- a/chalk.js +++ b/chalk.js @@ -38,7 +38,7 @@ function init() { return self._styles.reduce(function (str, name) { var code = ansi[name]; - return code[0] + (str || '') + code[1]; + return code.open + (str || '') + code.close; }, str); }, styles); diff --git a/package.json b/package.json index d645cab..654f7c7 100644 --- a/package.json +++ b/package.json @@ -44,11 +44,11 @@ }, "dependencies": { "has-color": "~0.1.0", - "ansi-styles": "~0.2.0", + "ansi-styles": "~1.0.0", "strip-ansi": "~0.1.0" }, "devDependencies": { - "mocha": "~1.12.0" + "mocha": "~1.x" }, "engines": { "node": ">=0.8.0" diff --git a/readme.md b/readme.md index 1378061..7c124c3 100644 --- a/readme.md +++ b/readme.md @@ -45,7 +45,7 @@ console.log(chalk.blue.bgRed.bold('Hello world!')); chalk.red('Hello', chalk.underline.bgBlue('world') + '!'); // pass in multiple arguments -console.log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz')) +console.log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz')); ``` You can easily define your own themes. @@ -85,15 +85,14 @@ Exposes the styles as [ANSI escape codes](https://github.com/sindresorhus/ansi-s var chalk = require('chalk'); console.log(chalk.styles.red); -//=> ['\x1b[31m', '\x1b[39m'] +//=> {open: '\x1b[31m', close: '\x1b[39m'} -console.log(chalk.styles.red[0] + 'Hello' + chalk.styles.red[1]); -// first item is the style escape code and second is the reset escape code +console.log(chalk.styles.red.open + 'Hello' + chalk.styles.red.close); ``` ### chalk.stripColor(string) -Strip color from a string. +[Strip color](https://github.com/sindresorhus/strip-ansi) from a string. ## Styles diff --git a/test.js b/test.js index 2241744..b27323f 100644 --- a/test.js +++ b/test.js @@ -49,7 +49,7 @@ describe('chalk.enabled', function () { describe('chalk.styles', function () { it('should expose the styles as ANSI escape codes', function () { - assert.equal(chalk.styles.red[0], '\x1b[31m'); + assert.equal(chalk.styles.red.open, '\x1b[31m'); }); });