summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-10 17:39:05 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-10 17:39:05 -0800
commit586d343d74de008d2ce62e15a5d153be173fd791 (patch)
tree6946c4f5d3335235c2c8f732ecc93c3e9c7f7499 /js
parent145424ab245350a4a6eec1adab8d57402677530e (diff)
Include a mini ansi implementation in test.js.
This way we don't need to depend on the ansi module at all.
Diffstat (limited to 'js')
-rwxr-xr-xjs/test.js36
1 files changed, 17 insertions, 19 deletions
diff --git a/js/test.js b/js/test.js
index a6184b3..2e8b5c3 100755
--- a/js/test.js
+++ b/js/test.js
@@ -3,26 +3,24 @@
var fs = require('fs');
var commonmark = require('./lib/index.js');
-var ansi;
-var cursor;
-try {
- ansi = require('ansi');
- cursor = ansi(process.stdout);
-}
-catch(err) {
- var noOp = function() { return this; };
- cursor = {
- write: function (s) {
- process.stdout.write(s);
- return this;
- },
- green: noOp,
- red: noOp,
- cyan: noOp,
- reset: noOp,
- };
-}
+// Home made mini-version of the npm ansi module:
+var escSeq = function(s) {
+ return function (){
+ process.stdout.write('\u001b' + s);
+ return this;
+ };
+};
+var cursor = {
+ write: function (s) {
+ process.stdout.write(s);
+ return this;
+ },
+ green: escSeq('[0;32m'),
+ red: escSeq('[0;31m'),
+ cyan: escSeq('[0;36m'),
+ reset: escSeq('[0;30m'),
+};
var writer = new commonmark.HtmlRenderer();
var reader = new commonmark.DocParser();