Skip to content

Commit

Permalink
Use an collection of colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Sep 14, 2017
1 parent 3aa9e8e commit bffbc8e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/Constants.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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']
11 changes: 5 additions & 6 deletions lib/Default.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
19 changes: 10 additions & 9 deletions test/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 ::', ->

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bffbc8e

Please sign in to comment.