Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for orange and bgOrange #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- white
- gray
- grey
- orange

### background colors

Expand All @@ -33,6 +34,7 @@
- bgMagenta
- bgCyan
- bgWhite
- bgOrange

### styles

Expand Down Expand Up @@ -84,7 +86,7 @@ console.log(colors.trap('Run the trap')); // Drops the bass

```

I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.

If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.

Expand Down
5 changes: 3 additions & 2 deletions lib/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var codes = {
white: [37, 39],
gray: [90, 39],
grey: [90, 39],
orange: ['38;2;255;153;0', 39],

bgBlack: [40, 49],
bgRed: [41, 49],
Expand All @@ -56,7 +57,7 @@ var codes = {
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49],

bgOrange: ['48;2;255;153;0', 49],
// legacy styles for colors pre v1.0.0
blackBG: [40, 49],
redBG: [41, 49],
Expand All @@ -74,4 +75,4 @@ Object.keys(codes).forEach(function (key) {
var style = styles[key] = [];
style.open = '\u001b[' + val[0] + 'm';
style.close = '\u001b[' + val[1] + 'm';
});
});
3 changes: 1 addition & 2 deletions tests/basic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function h(s, color) {
return '<span style="color:' + color + ';">' + s + '</span>';
}

var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow'];
var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow', 'orange'];
var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']);

colors.mode = 'console';
Expand Down Expand Up @@ -47,4 +47,3 @@ colors.setTheme({error:'red'});

assert.equal(typeof("astring".red),'string');
assert.equal(typeof("astring".error),'string');

6 changes: 4 additions & 2 deletions tests/safe-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function h(s, color) {
return '<span style="color:' + color + ';">' + s + '</span>';
}

var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow'];
var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow', 'orange'];
var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']);

colors.mode = 'console';
Expand All @@ -37,9 +37,11 @@ aE(s, 'green', 32);
aE(s, 'magenta', 35);
aE(s, 'red', 31);
aE(s, 'yellow', 33);
aE(s, 'orange', '38;2;255;153;0');


assert.equal(s, 'string');
colors.setTheme({error:'red'});

assert.equal(typeof(colors.red("astring")), 'string');
assert.equal(typeof(colors.error("astring")), 'string');
assert.equal(typeof(colors.error("astring")), 'string');