diff --git a/lib/carto/index.js b/lib/carto/index.js index 311b8cf..c319310 100644 --- a/lib/carto/index.js +++ b/lib/carto/index.js @@ -55,7 +55,7 @@ var carto = { if (typeof(extract[2]) === 'string') { error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey')); } - error = options.indent + error.join('\n' + options.indent) + '\033[0m\n'; + error = options.indent + error.join('\n' + options.indent) + '\x1B[0m\n'; message = options.indent + message + stylize(ctx.message, 'red'); if (ctx.filename) (message += stylize(' in ', 'red') + ctx.filename); @@ -113,6 +113,6 @@ function stylize(str, style) { 'red' : [31, 39], 'grey' : [90, 39] }; - return '\033[' + styles[style][0] + 'm' + str + - '\033[' + styles[style][1] + 'm'; + return '\x1B[' + styles[style][0] + 'm' + str + + '\x1B[' + styles[style][1] + 'm'; } diff --git a/package.json b/package.json index 86253a6..4b89812 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "scripts": { "pretest": "npm install", "test": "mocha -R spec", + "tdd" : "env HIDE_LOGS=true mocha -w -R spec", "coverage": "istanbul cover ./node_modules/.bin/_mocha && coveralls < ./coverage/lcov.info" } } diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index 17e7a91..b04cd44 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -1,4 +1,4 @@ - +var SHOW_LOGS = (process.env.HIDE_LOGS !== 'true'); var assert = require('assert'); var carto = require('../lib/carto'); describe('RenderingJS', function() { @@ -21,7 +21,7 @@ describe('RenderingJS', function() { ].join('\n'); beforeEach(function() { - shader = (new carto.RendererJS({ debug: true })).render(style); + shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); }); it ("shold render layers", function() { @@ -45,7 +45,7 @@ describe('RenderingJS', function() { it ("shold render variables", function() { var style = '#test { marker-width: [testing]; }'; - shader = (new carto.RendererJS({ debug: true })).render(style); + shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); var layer = shader.getLayers()[0]; var props = layer.getStyle({testing: 2}, { 'zoom': 0, 'frame-offset': 10 }); assert( props['marker-width'] === 2); @@ -53,7 +53,7 @@ describe('RenderingJS', function() { it ("should allow filter based rendering", function() { var style = '#test { marker-width: 10; [zoom = 1] { marker-width: 1; } }'; - shader = (new carto.RendererJS({ debug: true })).render(style); + shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); var layer = shader.getLayers()[0]; var props = layer.getStyle({}, { 'zoom': 0, 'frame-offset': 10 }); assert( props['marker-width'] === 10); @@ -64,7 +64,7 @@ describe('RenderingJS', function() { it ("symbolizers should be in rendering order", function() { var style = '#test { polygon-fill: red; line-color: red; }'; style += '#test2 { line-color: red;polygon-fill: red; line-width: 10; }'; - var shader = (new carto.RendererJS({ debug: true })).render(style); + var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); var layer0 = shader.getLayers()[0]; assert(layer0.getSymbolizers()[0] === 'polygon'); assert(layer0.getSymbolizers()[1] === 'line'); @@ -76,7 +76,7 @@ describe('RenderingJS', function() { it ("colorize should return a list of colours in same order", function() { var style = '#test { image-filters: colorize-alpha(blue, cyan, green, yellow, orange, red); }'; - var shader = (new carto.RendererJS({ debug: true })).render(style); + var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); var layer0 = shader.getLayers()[0]; var st = layer0.getStyle({ value: 1 }, {"frame-offset": 0, "zoom": 3}); var expectedColours = [[0, 0, 255], [0, 255, 255], [0, 128, 0], [255, 255, 0], [255, 165, 0], [255, 0, 0]]; @@ -106,7 +106,7 @@ describe('RenderingJS', function() { ' [frame-offset = 2] { marker-width: 15; marker-fill-opacity: 0.02;}', '}' ].join('\n'); - var shader = (new carto.RendererJS({ debug: true })).render(css); + var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(css); var markerURLs = shader.getImageURLs(); var against = ["http://localhost:8081/gal.svg", "http://upload.wikimedia.org/wikipedia/commons/4/43/Flag_of_the_Galactic_Empire.svg", "http://upload.wikimedia.org/wikipedia/commons/c/c9/Flag_of_Syldavia.svg"]; for(var i = 0; i