Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Get rid of octal escape sequences

Jonas Westerlundd1fe8fb8e92b
diff --git a/bin/_mocha b/bin/_mocha
index 022f7ef2..86d17908 100755
--- a/bin/_mocha
+++ b/bin/_mocha
@@ -247,12 +247,12 @@ if (program.watch) {
});
var frames = [
- ' \033[96m◜ \033[90mwatching\033[0m'
- , ' \033[96m◠ \033[90mwatching\033[0m'
- , ' \033[96m◝ \033[90mwatching\033[0m'
- , ' \033[96m◞ \033[90mwatching\033[0m'
- , ' \033[96m◡ \033[90mwatching\033[0m'
- , ' \033[96m◟ \033[90mwatching\033[0m'
+ ' \u001b[96m◜ \u001b[90mwatching\u001b[0m'
+ , ' \u001b[96m◠ \u001b[90mwatching\u001b[0m'
+ , ' \u001b[96m◝ \u001b[90mwatching\u001b[0m'
+ , ' \u001b[96m◞ \u001b[90mwatching\u001b[0m'
+ , ' \u001b[96m◡ \u001b[90mwatching\u001b[0m'
+ , ' \u001b[96m◟ \u001b[90mwatching\u001b[0m'
];
var watchFiles = utils.files(cwd);
@@ -350,7 +350,7 @@ function list(str) {
*/
function hideCursor(){
- process.stdout.write('\033[?25l');
+ process.stdout.write('\u001b[?25l');
};
/**
@@ -358,7 +358,7 @@ function hideCursor(){
*/
function showCursor(){
- process.stdout.write('\033[?25h');
+ process.stdout.write('\u001b[?25h');
};
/**
@@ -366,7 +366,7 @@ function showCursor(){
*/
function stop() {
- process.stdout.write('\033[2K');
+ process.stdout.write('\u001b[2K');
clearInterval(play.timer);
}
diff --git a/lib/reporters/base.js b/lib/reporters/base.js
index a4cc271c..c8132960 100644
--- a/lib/reporters/base.js
+++ b/lib/reporters/base.js
@@ -74,7 +74,7 @@ exports.colors = {
var color = exports.color = function(type, str) {
if (!exports.useColors) return str;
- return '\033[' + exports.colors[type] + 'm' + str + '\033[0m';
+ return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
};
/**
@@ -97,19 +97,19 @@ exports.window = {
exports.cursor = {
hide: function(){
- process.stdout.write('\033[?25l');
+ process.stdout.write('\u001b[?25l');
},
show: function(){
- process.stdout.write('\033[?25h');
+ process.stdout.write('\u001b[?25h');
},
deleteLine: function(){
- process.stdout.write('\033[2K');
+ process.stdout.write('\u001b[2K');
},
beginningOfLine: function(){
- process.stdout.write('\033[0G');
+ process.stdout.write('\u001b[0G');
},
CR: function(){
diff --git a/lib/reporters/landing.js b/lib/reporters/landing.js
index 8d59e505..bf064f64 100644
--- a/lib/reporters/landing.js
+++ b/lib/reporters/landing.js
@@ -73,14 +73,14 @@ function Landing(runner) {
}
// render landing strip
- stream.write('\033[4F\n\n');
+ stream.write('\u001b[4F\n\n');
stream.write(runway());
stream.write('\n ');
stream.write(color('runway', Array(col).join('⋅')));
stream.write(plane)
stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
stream.write(runway());
- stream.write('\033[0m');
+ stream.write('\u001b[0m');
});
runner.on('end', function(){
diff --git a/lib/reporters/min.js b/lib/reporters/min.js
index 9f3cea1a..323bb330 100644
--- a/lib/reporters/min.js
+++ b/lib/reporters/min.js
@@ -22,9 +22,9 @@ function Min(runner) {
runner.on('start', function(){
// clear screen
- process.stdout.write('\033[2J');
+ process.stdout.write('\u001b[2J');
// set cursor position
- process.stdout.write('\033[1;3H');
+ process.stdout.write('\u001b[1;3H');
});
runner.on('end', this.epilogue.bind(this));
diff --git a/lib/reporters/nyan.js b/lib/reporters/nyan.js
index f1732f86..d8b92c36 100644
--- a/lib/reporters/nyan.js
+++ b/lib/reporters/nyan.js
@@ -87,7 +87,7 @@ NyanCat.prototype.drawScoreboard = function(){
function draw(color, n) {
write(' ');
- write('\033[' + color + 'm' + n + '\033[0m');
+ write('\u001b[' + color + 'm' + n + '\u001b[0m');
write('\n');
}
@@ -126,7 +126,7 @@ NyanCat.prototype.drawRainbow = function(){
var self = this;
this.trajectories.forEach(function(line, index) {
- write('\033[' + self.scoreboardWidth + 'C');
+ write('\u001b[' + self.scoreboardWidth + 'C');
write(line.join(''));
write('\n');
});
@@ -146,7 +146,7 @@ NyanCat.prototype.drawNyanCat = function(status) {
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
[0, 1, 2, 3].forEach(function(index) {
- write('\033[' + startWidth + 'C');
+ write('\u001b[' + startWidth + 'C');
switch (index) {
case 0:
@@ -194,7 +194,7 @@ NyanCat.prototype.drawNyanCat = function(status) {
*/
NyanCat.prototype.cursorUp = function(n) {
- write('\033[' + n + 'A');
+ write('\u001b[' + n + 'A');
};
/**
@@ -205,7 +205,7 @@ NyanCat.prototype.cursorUp = function(n) {
*/
NyanCat.prototype.cursorDown = function(n) {
- write('\033[' + n + 'B');
+ write('\u001b[' + n + 'B');
};
/**
@@ -241,7 +241,7 @@ NyanCat.prototype.generateColors = function(){
NyanCat.prototype.rainbowify = function(str){
var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
this.colorIndex += 1;
- return '\033[38;5;' + color + 'm' + str + '\033[0m';
+ return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
};
/**
diff --git a/lib/reporters/progress.js b/lib/reporters/progress.js
index 8e0af1b7..143b1a0d 100644
--- a/lib/reporters/progress.js
+++ b/lib/reporters/progress.js
@@ -60,7 +60,7 @@ function Progress(runner, options) {
, i = width - n;
cursor.CR();
- process.stdout.write('\033[J');
+ process.stdout.write('\u001b[J');
process.stdout.write(color('progress', ' ' + options.open));
process.stdout.write(Array(n).join(options.complete));
process.stdout.write(Array(i).join(options.incomplete));
diff --git a/mocha.js b/mocha.js
index 05ad4d82..4c383024 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1134,7 +1134,7 @@ exports.colors = {
var color = exports.color = function(type, str) {
if (!exports.useColors) return str;
- return '\033[' + exports.colors[type] + 'm' + str + '\033[0m';
+ return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
};
/**
@@ -1157,19 +1157,19 @@ exports.window = {
exports.cursor = {
hide: function(){
- process.stdout.write('\033[?25l');
+ process.stdout.write('\u001b[?25l');
},
show: function(){
- process.stdout.write('\033[?25h');
+ process.stdout.write('\u001b[?25h');
},
deleteLine: function(){
- process.stdout.write('\033[2K');
+ process.stdout.write('\u001b[2K');
},
beginningOfLine: function(){
- process.stdout.write('\033[0G');
+ process.stdout.write('\u001b[0G');
},
CR: function(){
@@ -2191,14 +2191,14 @@ function Landing(runner) {
}
// render landing strip
- stream.write('\033[4F\n\n');
+ stream.write('\u001b[4F\n\n');
stream.write(runway());
stream.write('\n ');
stream.write(color('runway', Array(col).join('⋅')));
stream.write(plane)
stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
stream.write(runway());
- stream.write('\033[0m');
+ stream.write('\u001b[0m');
});
runner.on('end', function(){
@@ -2407,9 +2407,9 @@ function Min(runner) {
runner.on('start', function(){
// clear screen
- process.stdout.write('\033[2J');
+ process.stdout.write('\u001b[2J');
// set cursor position
- process.stdout.write('\033[1;3H');
+ process.stdout.write('\u001b[1;3H');
});
runner.on('end', this.epilogue.bind(this));
@@ -2514,7 +2514,7 @@ NyanCat.prototype.drawScoreboard = function(){
function draw(color, n) {
write(' ');
- write('\033[' + color + 'm' + n + '\033[0m');
+ write('\u001b[' + color + 'm' + n + '\u001b[0m');
write('\n');
}
@@ -2553,7 +2553,7 @@ NyanCat.prototype.drawRainbow = function(){
var self = this;
this.trajectories.forEach(function(line, index) {
- write('\033[' + self.scoreboardWidth + 'C');
+ write('\u001b[' + self.scoreboardWidth + 'C');
write(line.join(''));
write('\n');
});
@@ -2573,7 +2573,7 @@ NyanCat.prototype.drawNyanCat = function(status) {
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
[0, 1, 2, 3].forEach(function(index) {
- write('\033[' + startWidth + 'C');
+ write('\u001b[' + startWidth + 'C');
switch (index) {
case 0:
@@ -2621,7 +2621,7 @@ NyanCat.prototype.drawNyanCat = function(status) {
*/
NyanCat.prototype.cursorUp = function(n) {
- write('\033[' + n + 'A');
+ write('\u001b[' + n + 'A');
};
/**
@@ -2632,7 +2632,7 @@ NyanCat.prototype.cursorUp = function(n) {
*/
NyanCat.prototype.cursorDown = function(n) {
- write('\033[' + n + 'B');
+ write('\u001b[' + n + 'B');
};
/**
@@ -2668,7 +2668,7 @@ NyanCat.prototype.generateColors = function(){
NyanCat.prototype.rainbowify = function(str){
var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
this.colorIndex += 1;
- return '\033[38;5;' + color + 'm' + str + '\033[0m';
+ return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
};
/**
@@ -2752,7 +2752,7 @@ function Progress(runner, options) {
, i = width - n;
cursor.CR();
- process.stdout.write('\033[J');
+ process.stdout.write('\u001b[J');
process.stdout.write(color('progress', ' ' + options.open));
process.stdout.write(Array(n).join(options.complete));
process.stdout.write(Array(i).join(options.incomplete));
diff --git a/support/compile.js b/support/compile.js
index 2bcf367f..ca13d769 100644
--- a/support/compile.js
+++ b/support/compile.js
@@ -21,7 +21,7 @@ args.forEach(function(file){
var mod = file.replace('lib/', '');
fs.readFile(file, 'utf8', function(err, js){
if (err) throw err;
- console.log(' \033[90mcompile : \033[0m\033[36m%s\033[0m', file);
+ console.log(' \u001b[90mcompile : \u001b[0m\u001b[36m%s\u001b[0m', file);
files[file] = ~js.indexOf('require: off')
? js
: parse(js);
@@ -84,7 +84,7 @@ function compile() {
});
fs.writeFile('_mocha.js', buf, function(err){
if (err) throw err;
- console.log(' \033[90m create : \033[0m\033[36m%s\033[0m', 'mocha.js');
+ console.log(' \u001b[90m create : \u001b[0m\u001b[36m%s\u001b[0m', 'mocha.js');
console.log();
});
}