Skip to content
This repository
Browse code

Merge pull request #28 from timelesshaze/master

[fix] Changed octal literals to hexadecimal
  • Loading branch information...
commit e5fe67f826162e088822da8e7c8f58ff80e1ee66 2 parents e9604a5 + e8f50c4
authored

Showing 2 changed files with 19 additions and 19 deletions. Show diff stats Hide diff stats

  1. +14 14 colors.js
  2. +5 5 test.js
28 colors.js
@@ -62,21 +62,21 @@ function stylize(str, style) {
62 62 if (exports.mode === 'console') {
63 63 styles = {
64 64 //styles
65   - 'bold' : ['\033[1m', '\033[22m'],
66   - 'italic' : ['\033[3m', '\033[23m'],
67   - 'underline' : ['\033[4m', '\033[24m'],
68   - 'inverse' : ['\033[7m', '\033[27m'],
  65 + 'bold' : ['\x1B[1m', '\x1B[22m'],
  66 + 'italic' : ['\x1B[3m', '\x1B[23m'],
  67 + 'underline' : ['\x1B[4m', '\x1B[24m'],
  68 + 'inverse' : ['\x1B[7m', '\x1B[27m'],
69 69 //grayscale
70   - 'white' : ['\033[37m', '\033[39m'],
71   - 'grey' : ['\033[90m', '\033[39m'],
72   - 'black' : ['\033[30m', '\033[39m'],
  70 + 'white' : ['\x1B[37m', '\x1B[39m'],
  71 + 'grey' : ['\x1B[90m', '\x1B[39m'],
  72 + 'black' : ['\x1B[30m', '\x1B[39m'],
73 73 //colors
74   - 'blue' : ['\033[34m', '\033[39m'],
75   - 'cyan' : ['\033[36m', '\033[39m'],
76   - 'green' : ['\033[32m', '\033[39m'],
77   - 'magenta' : ['\033[35m', '\033[39m'],
78   - 'red' : ['\033[31m', '\033[39m'],
79   - 'yellow' : ['\033[33m', '\033[39m']
  74 + 'blue' : ['\x1B[34m', '\x1B[39m'],
  75 + 'cyan' : ['\x1B[36m', '\x1B[39m'],
  76 + 'green' : ['\x1B[32m', '\x1B[39m'],
  77 + 'magenta' : ['\x1B[35m', '\x1B[39m'],
  78 + 'red' : ['\x1B[31m', '\x1B[39m'],
  79 + 'yellow' : ['\x1B[33m', '\x1B[39m']
80 80 };
81 81 } else if (exports.mode === 'browser') {
82 82 styles = {
@@ -194,7 +194,7 @@ exports.setTheme = function (theme) {
194 194
195 195
196 196 addProperty('stripColors', function () {
197   - return ("" + this).replace(/\u001b\[\d+m/g, '');
  197 + return ("" + this).replace(/\x1B\[\d+m/g, '');
198 198 });
199 199
200 200 // please no
10 test.js
@@ -10,7 +10,7 @@ var assert = require('assert'),
10 10 var s = 'string';
11 11
12 12 function a(s, code) {
13   - return '\033[' + code.toString() + 'm' + s + '\033[39m';
  13 + return '\x1B[' + code.toString() + 'm' + s + '\x1B[39m';
14 14 }
15 15
16 16 function aE(s, color, code) {
@@ -30,10 +30,10 @@ var stylesColors = ['white', 'grey', 'black', 'blue', 'cyan', 'green', 'magenta'
30 30 var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']);
31 31
32 32 colors.mode = 'console';
33   -assert.equal(s.bold, '\033[1m' + s + '\033[22m');
34   -assert.equal(s.italic, '\033[3m' + s + '\033[23m');
35   -assert.equal(s.underline, '\033[4m' + s + '\033[24m');
36   -assert.equal(s.inverse, '\033[7m' + s + '\033[27m');
  33 +assert.equal(s.bold, '\x1B[1m' + s + '\x1B[22m');
  34 +assert.equal(s.italic, '\x1B[3m' + s + '\x1B[23m');
  35 +assert.equal(s.underline, '\x1B[4m' + s + '\x1B[24m');
  36 +assert.equal(s.inverse, '\x1B[7m' + s + '\x1B[27m');
37 37 assert.ok(s.rainbow);
38 38 aE(s, 'white', 37);
39 39 aE(s, 'grey', 90);

0 comments on commit e5fe67f

Please sign in to comment.
Something went wrong with that request. Please try again.