Update to latest ansi-styles

This commit is contained in:
Sindre Sorhus 2013-12-08 01:02:35 +01:00
parent a66c486301
commit 879defda72
4 changed files with 8 additions and 9 deletions

View file

@ -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);

View file

@ -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"

View file

@ -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

View file

@ -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');
});
});