diff --git a/lib/Constants.coffee b/lib/Constants.coffee index d4c2289..94dc53d 100644 --- a/lib/Constants.coffee +++ b/lib/Constants.coffee @@ -16,7 +16,7 @@ figure = module.exports = DECORATE_COUNTER_ZERO_N : 4 UNMUTED : 'all' - LINE_COLOR : 'gray' + LINE_COLOR : ['gray'] SYMBOL_KEYWORD : 'symbol' MUTED : 'muted' FIGURE : figure[process.platform is 'win32'] diff --git a/lib/Default.coffee b/lib/Default.coffee index a878492..66239eb 100644 --- a/lib/Default.coffee +++ b/lib/Default.coffee @@ -114,7 +114,6 @@ module.exports = () -> colorize: (colors, message) -> return message unless @color - colors = colors.split ' ' (stylize = getColor color) for color in colors stylize message @@ -141,27 +140,27 @@ module.exports = () -> types: debug: level : 4 - color : 'white' + color : ['white'] symbol: CONST.FIGURE.info info: level : 3 - color : '#33ccff' + color : ['#33ccff'] separator : ' ' symbol : CONST.FIGURE.info warn: level : 2 - color : '#ffcc33' + color : ['#ffcc33'] separator : ' ' symbol : CONST.FIGURE.warning error: level : 1 - color : '#FF3333' + color : ['#FF3333'] symbol : CONST.FIGURE.error fatal: level : 0 - color : '#ff3366' + color : ['#ff3366'] symbol : CONST.FIGURE.error diff --git a/test/test.coffee b/test/test.coffee index 3fd08a0..97e0399 100755 --- a/test/test.coffee +++ b/test/test.coffee @@ -4,12 +4,11 @@ Acho = require '..' util = require './util' should = require 'should' -createAcho = -> - Acho - color: true - outputType: (type) -> "[#{type}] » " - transport: util.createFakeTransport() - +createAcho = (opts) -> Acho(Object.assign({}, { + color: true + outputType: (type) -> "[#{type}] » " + transport: util.createFakeTransport() + }, opts)) describe 'Acho ::', -> @@ -61,15 +60,17 @@ describe 'Acho ::', -> @acho.transport.store[0].should.be.equal expected it 'change the color behavior', -> - acho = createAcho() - acho.types.error.color = 'underline bgRed' + acho = createAcho( + types: error: color: ['underline', 'bgRed'] + ) + acho.push 'error', 'hello world' acho.print() acho.transport.store.length.should.be.equal 1 expected = '\u001b[41m[error] » \u001b[49m \u001b[90mhello world\u001b[39m' acho.transport.store[0].should.be.equal expected - Acho.defaults().types.error.color.should.be.equal('#FF3333') + Acho.defaults().types.error.color.should.be.eql(['#FF3333']) it 'no ouptut messages out of the level', -> level = @acho.level