Skip to content

Commit

Permalink
Merge pull request #28 from timelesshaze/master
Browse files Browse the repository at this point in the history
[fix] Changed octal literals to hexadecimal
  • Loading branch information
Marak committed Sep 6, 2012
2 parents e9604a5 + e8f50c4 commit e5fe67f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
28 changes: 14 additions & 14 deletions colors.js
Expand Up @@ -62,21 +62,21 @@ function stylize(str, style) {
if (exports.mode === 'console') { if (exports.mode === 'console') {
styles = { styles = {
//styles //styles
'bold' : ['\033[1m', '\033[22m'], 'bold' : ['\x1B[1m', '\x1B[22m'],
'italic' : ['\033[3m', '\033[23m'], 'italic' : ['\x1B[3m', '\x1B[23m'],
'underline' : ['\033[4m', '\033[24m'], 'underline' : ['\x1B[4m', '\x1B[24m'],
'inverse' : ['\033[7m', '\033[27m'], 'inverse' : ['\x1B[7m', '\x1B[27m'],
//grayscale //grayscale
'white' : ['\033[37m', '\033[39m'], 'white' : ['\x1B[37m', '\x1B[39m'],
'grey' : ['\033[90m', '\033[39m'], 'grey' : ['\x1B[90m', '\x1B[39m'],
'black' : ['\033[30m', '\033[39m'], 'black' : ['\x1B[30m', '\x1B[39m'],
//colors //colors
'blue' : ['\033[34m', '\033[39m'], 'blue' : ['\x1B[34m', '\x1B[39m'],
'cyan' : ['\033[36m', '\033[39m'], 'cyan' : ['\x1B[36m', '\x1B[39m'],
'green' : ['\033[32m', '\033[39m'], 'green' : ['\x1B[32m', '\x1B[39m'],
'magenta' : ['\033[35m', '\033[39m'], 'magenta' : ['\x1B[35m', '\x1B[39m'],
'red' : ['\033[31m', '\033[39m'], 'red' : ['\x1B[31m', '\x1B[39m'],
'yellow' : ['\033[33m', '\033[39m'] 'yellow' : ['\x1B[33m', '\x1B[39m']
}; };
} else if (exports.mode === 'browser') { } else if (exports.mode === 'browser') {
styles = { styles = {
Expand Down Expand Up @@ -194,7 +194,7 @@ exports.setTheme = function (theme) {




addProperty('stripColors', function () { addProperty('stripColors', function () {
return ("" + this).replace(/\u001b\[\d+m/g, ''); return ("" + this).replace(/\x1B\[\d+m/g, '');
}); });


// please no // please no
Expand Down
10 changes: 5 additions & 5 deletions test.js
Expand Up @@ -10,7 +10,7 @@ var assert = require('assert'),
var s = 'string'; var s = 'string';


function a(s, code) { function a(s, code) {
return '\033[' + code.toString() + 'm' + s + '\033[39m'; return '\x1B[' + code.toString() + 'm' + s + '\x1B[39m';
} }


function aE(s, color, code) { function aE(s, color, code) {
Expand All @@ -30,10 +30,10 @@ var stylesColors = ['white', 'grey', 'black', 'blue', 'cyan', 'green', 'magenta'
var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']); var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']);


colors.mode = 'console'; colors.mode = 'console';
assert.equal(s.bold, '\033[1m' + s + '\033[22m'); assert.equal(s.bold, '\x1B[1m' + s + '\x1B[22m');
assert.equal(s.italic, '\033[3m' + s + '\033[23m'); assert.equal(s.italic, '\x1B[3m' + s + '\x1B[23m');
assert.equal(s.underline, '\033[4m' + s + '\033[24m'); assert.equal(s.underline, '\x1B[4m' + s + '\x1B[24m');
assert.equal(s.inverse, '\033[7m' + s + '\033[27m'); assert.equal(s.inverse, '\x1B[7m' + s + '\x1B[27m');
assert.ok(s.rainbow); assert.ok(s.rainbow);
aE(s, 'white', 37); aE(s, 'white', 37);
aE(s, 'grey', 90); aE(s, 'grey', 90);
Expand Down

0 comments on commit e5fe67f

Please sign in to comment.