ansi-styles 0.1.1 → 1.1.0
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 +40 -0
- package/package.json +19 -25
- package/readme.md +36 -42
- package/ansi-styles.js +0 -31
package/index.js
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
'use strict';
|
2
|
+
var styles = module.exports;
|
3
|
+
|
4
|
+
var codes = {
|
5
|
+
reset: [0, 0],
|
6
|
+
|
7
|
+
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
|
8
|
+
dim: [2, 22],
|
9
|
+
italic: [3, 23],
|
10
|
+
underline: [4, 24],
|
11
|
+
inverse: [7, 27],
|
12
|
+
hidden: [8, 28],
|
13
|
+
strikethrough: [9, 29],
|
14
|
+
|
15
|
+
black: [30, 39],
|
16
|
+
red: [31, 39],
|
17
|
+
green: [32, 39],
|
18
|
+
yellow: [33, 39],
|
19
|
+
blue: [34, 39],
|
20
|
+
magenta: [35, 39],
|
21
|
+
cyan: [36, 39],
|
22
|
+
white: [37, 39],
|
23
|
+
gray: [90, 39],
|
24
|
+
|
25
|
+
bgBlack: [40, 49],
|
26
|
+
bgRed: [41, 49],
|
27
|
+
bgGreen: [42, 49],
|
28
|
+
bgYellow: [43, 49],
|
29
|
+
bgBlue: [44, 49],
|
30
|
+
bgMagenta: [45, 49],
|
31
|
+
bgCyan: [46, 49],
|
32
|
+
bgWhite: [47, 49]
|
33
|
+
};
|
34
|
+
|
35
|
+
Object.keys(codes).forEach(function (key) {
|
36
|
+
var val = codes[key];
|
37
|
+
var style = styles[key] = {};
|
38
|
+
style.open = '\u001b[' + val[0] + 'm';
|
39
|
+
style.close = '\u001b[' + val[1] + 'm';
|
40
|
+
});
|
package/package.json
CHANGED
@@ -1,7 +1,23 @@
|
|
1
1
|
{
|
2
2
|
"name": "ansi-styles",
|
3
|
-
"version": "
|
4
|
-
"description": "ANSI escape codes for
|
3
|
+
"version": "1.1.0",
|
4
|
+
"description": "ANSI escape codes for styling strings in the terminal",
|
5
|
+
"license": "MIT",
|
6
|
+
"repository": "sindresorhus/ansi-styles",
|
7
|
+
"author": {
|
8
|
+
"name": "Sindre Sorhus",
|
9
|
+
"email": "sindresorhus@gmail.com",
|
10
|
+
"url": "http://sindresorhus.com"
|
11
|
+
},
|
12
|
+
"engines": {
|
13
|
+
"node": ">=0.10.0"
|
14
|
+
},
|
15
|
+
"scripts": {
|
16
|
+
"test": "mocha"
|
17
|
+
},
|
18
|
+
"files": [
|
19
|
+
"index.js"
|
20
|
+
],
|
5
21
|
"keywords": [
|
6
22
|
"ansi",
|
7
23
|
"styles",
|
@@ -24,29 +40,7 @@
|
|
24
40
|
"command-line",
|
25
41
|
"text"
|
26
42
|
],
|
27
|
-
"homepage": "https://github.com/sindresorhus/ansi-styles",
|
28
|
-
"bugs": "https://github.com/sindresorhus/ansi-styles/issues",
|
29
|
-
"license": "MIT",
|
30
|
-
"author": {
|
31
|
-
"name": "Sindre Sorhus",
|
32
|
-
"email": "sindresorhus@gmail.com",
|
33
|
-
"url": "http://sindresorhus.com"
|
34
|
-
},
|
35
|
-
"files": [
|
36
|
-
"ansi-styles.js"
|
37
|
-
],
|
38
|
-
"main": "ansi-styles",
|
39
|
-
"repository": {
|
40
|
-
"type": "git",
|
41
|
-
"url": "git://github.com/sindresorhus/ansi-styles.git"
|
42
|
-
},
|
43
|
-
"scripts": {
|
44
|
-
"test": "mocha"
|
45
|
-
},
|
46
43
|
"devDependencies": {
|
47
|
-
"mocha": "
|
48
|
-
},
|
49
|
-
"engines": {
|
50
|
-
"node": ">=0.8.0"
|
44
|
+
"mocha": "*"
|
51
45
|
}
|
52
46
|
}
|
package/readme.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# ansi-styles [](https://travis-ci.org/sindresorhus/ansi-styles)
|
2
2
|
|
3
|
-
> ANSI escape codes for
|
3
|
+
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
4
4
|
|
5
5
|
You probably want the higher-level [chalk](https://github.com/sindresorhus/chalk) module for styling your strings.
|
6
6
|
|
@@ -9,68 +9,62 @@ You probably want the higher-level [chalk](https://github.com/sindresorhus/chalk
|
|
9
9
|
|
10
10
|
## Install
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
```sh
|
13
|
+
$ npm install --save ansi-styles
|
14
|
+
```
|
14
15
|
|
15
|
-
## Example
|
16
16
|
|
17
|
-
|
17
|
+
## Usage
|
18
18
|
|
19
19
|
```js
|
20
20
|
var ansi = require('ansi-styles');
|
21
21
|
|
22
|
-
console.log(ansi.green + '
|
22
|
+
console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
|
23
|
+
```
|
23
24
|
|
24
|
-
Object.keys(ansi).forEach(function (el) {
|
25
|
-
var style = ansi[el];
|
26
25
|
|
27
|
-
|
28
|
-
style = ansi.black + style;
|
29
|
-
}
|
26
|
+
## API
|
30
27
|
|
31
|
-
|
32
|
-
});
|
33
|
-
```
|
28
|
+
Each style has an `open` and `close` property.
|
34
29
|
|
35
30
|
|
36
31
|
## Styles
|
37
32
|
|
38
33
|
### General
|
39
34
|
|
40
|
-
- reset
|
41
|
-
- bold
|
42
|
-
-
|
43
|
-
-
|
44
|
-
-
|
45
|
-
- inverse
|
46
|
-
-
|
35
|
+
- `reset`
|
36
|
+
- `bold`
|
37
|
+
- `dim`
|
38
|
+
- `italic` *(not widely supported)*
|
39
|
+
- `underline`
|
40
|
+
- `inverse`
|
41
|
+
- `hidden`
|
42
|
+
- `strikethrough` *(not widely supported)*
|
47
43
|
|
48
44
|
### Text colors
|
49
45
|
|
50
|
-
- black
|
51
|
-
- red
|
52
|
-
- green
|
53
|
-
- yellow
|
54
|
-
- blue
|
55
|
-
- magenta
|
56
|
-
- cyan
|
57
|
-
- white
|
58
|
-
-
|
59
|
-
- gray
|
46
|
+
- `black`
|
47
|
+
- `red`
|
48
|
+
- `green`
|
49
|
+
- `yellow`
|
50
|
+
- `blue`
|
51
|
+
- `magenta`
|
52
|
+
- `cyan`
|
53
|
+
- `white`
|
54
|
+
- `gray`
|
60
55
|
|
61
56
|
### Background colors
|
62
57
|
|
63
|
-
- bgBlack
|
64
|
-
- bgRed
|
65
|
-
- bgGreen
|
66
|
-
- bgYellow
|
67
|
-
- bgBlue
|
68
|
-
- bgMagenta
|
69
|
-
- bgCyan
|
70
|
-
- bgWhite
|
71
|
-
- bgDefault
|
58
|
+
- `bgBlack`
|
59
|
+
- `bgRed`
|
60
|
+
- `bgGreen`
|
61
|
+
- `bgYellow`
|
62
|
+
- `bgBlue`
|
63
|
+
- `bgMagenta`
|
64
|
+
- `bgCyan`
|
65
|
+
- `bgWhite`
|
72
66
|
|
73
67
|
|
74
68
|
## License
|
75
69
|
|
76
|
-
MIT
|
70
|
+
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
package/ansi-styles.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
module.exports = {
|
3
|
-
reset: '\x1b[0m',
|
4
|
-
bold: '\x1b[1m',
|
5
|
-
italic: '\x1b[3m',
|
6
|
-
underline: '\x1b[4m',
|
7
|
-
blink: '\x1b[5m',
|
8
|
-
inverse: '\x1b[7m',
|
9
|
-
strikethrough: '\x1b[9m',
|
10
|
-
|
11
|
-
black: '\x1b[30m',
|
12
|
-
red: '\x1b[31m',
|
13
|
-
green: '\x1b[32m',
|
14
|
-
yellow: '\x1b[33m',
|
15
|
-
blue: '\x1b[34m',
|
16
|
-
magenta: '\x1b[35m',
|
17
|
-
cyan: '\x1b[36m',
|
18
|
-
white: '\x1b[37m',
|
19
|
-
default: '\x1b[39m',
|
20
|
-
gray: '\x1B[90m',
|
21
|
-
|
22
|
-
bgBlack: '\x1b[40m',
|
23
|
-
bgRed: '\x1b[41m',
|
24
|
-
bgGreen: '\x1b[42m',
|
25
|
-
bgYellow: '\x1b[43m',
|
26
|
-
bgBlue: '\x1b[44m',
|
27
|
-
bgMagenta: '\x1b[45m',
|
28
|
-
bgCyan: '\x1b[46m',
|
29
|
-
bgWhite: '\x1b[47m',
|
30
|
-
bgDefault: '\x1b[49m'
|
31
|
-
};
|