diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-05-13 07:50:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-13 07:50:02 +0800 |
commit | 1a0d6edc81ccf2c678faec15c86486c688113f33 (patch) | |
tree | f98ecbb64d264abbfbded0bb9b979b1d877d118b /test/mocha.js | |
parent | 7b59b2f5b299893aaf7130af0498c8f477b25a4b (diff) | |
download | tracifyjs-1a0d6edc81ccf2c678faec15c86486c688113f33.tar.gz tracifyjs-1a0d6edc81ccf2c678faec15c86486c688113f33.zip |
remove `colors` dependency (#3133)
Diffstat (limited to 'test/mocha.js')
-rw-r--r-- | test/mocha.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/test/mocha.js b/test/mocha.js index 9902d653..503afd3d 100644 --- a/test/mocha.js +++ b/test/mocha.js @@ -1,4 +1,3 @@ -var colors = require("colors"); var fs = require("fs"); var config = { @@ -39,6 +38,14 @@ function log_titles(log, current, marker) { titles = current; } +function red(text) { + return "\u001B[31m" + text + "\u001B[39m"; +} + +function green(text) { + return "\u001B[32m" + text + "\u001B[39m"; +} + var errors = []; var total = tasks.length; titles = []; @@ -54,7 +61,7 @@ process.nextTick(function run() { if (elapsed > task.limit) { throw new Error("Timed out: " + elapsed + "ms > " + task.limit + "ms"); } - log_titles(console.log, task.titles, colors.green('\u221A ')); + log_titles(console.log, task.titles, green('\u221A ')); process.nextTick(run); }; if (task.length) { @@ -76,19 +83,19 @@ process.nextTick(function run() { raise(err); } else if (errors.length) { console.error(); - console.log(colors.red(errors.length + " test(s) failed!")); + console.log(red(errors.length + " test(s) failed!")); titles = []; errors.forEach(function(titles, index) { console.error(); log_titles(console.error, titles, (index + 1) + ") "); var lines = titles.error.stack.split('\n'); - console.error(colors.red(lines[0])); + console.error(red(lines[0])); console.error(lines.slice(1).join("\n")); }); process.exit(1); } else { console.log(); - console.log(colors.green(total + " test(s) passed.")); + console.log(green(total + " test(s) passed.")); } function raise(err) { @@ -96,7 +103,7 @@ process.nextTick(function run() { done = function() {}; task.titles.error = err; errors.push(task.titles); - log_titles(console.log, task.titles, colors.red('\u00D7 ')); + log_titles(console.log, task.titles, red('\u00D7 ')); process.nextTick(run); } }); |