Skip to content

Commit

Permalink
Better smart colorize
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed May 26, 2016
1 parent 0edb2a5 commit a7b2c78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Default.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ module.exports =

colorizeMessage: (type, message) ->
return stripAnsi message unless @color

lineColor = CONST.LINE_COLOR
return @colorize lineColor, message if message.indexOf '=' is -1
typeColor = @types[type].color

message.toString().split(' ').map((msg) =>
Expand Down
8 changes: 4 additions & 4 deletions test/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe 'Acho ::', ->

instance.print()
instance.transport.store.length.should.be.equal 1
expected = ' \u001b[34minfo\u001b[39m \u001b[90minfo\u001b[39m \u001b[90mmessage\u001b[39m'
expected = ' \u001b[34minfo\u001b[39m \u001b[90minfo message\u001b[39m'
instance.transport.store[0].should.be.equal expected

it '.push: add message into a internal level collection', ->
Expand All @@ -44,7 +44,7 @@ describe 'Acho ::', ->
@acho.transport.store.length.should.be.equal 1
@acho.messages.error.length.should.be.equal 1

expected = '\u001b[31m[error] » \u001b[39m \u001b[90mhello\u001b[39m \u001b[90mworld\u001b[39m'
expected = '\u001b[31m[error] » \u001b[39m \u001b[90mhello world\u001b[39m'
@acho.transport.store[0].should.be.equal expected
@acho.messages.error[0].should.be.equal 'hello world'

Expand All @@ -54,7 +54,7 @@ describe 'Acho ::', ->
@acho.warn 'warn message'

@acho.transport.store.length.should.be.equal 1
expected = ' \u001b[33m[warn] » \u001b[39m \u001b[90mwarn\u001b[39m \u001b[90mmessage\u001b[39m'
expected = ' \u001b[33m[warn] » \u001b[39m \u001b[90mwarn message\u001b[39m'
@acho.transport.store[0].should.be.equal expected

it 'change the color behavior', ->
Expand All @@ -63,7 +63,7 @@ describe 'Acho ::', ->
@acho.print()

@acho.transport.store.length.should.be.equal 1
expected = '\u001b[31m\u001b[1m[error] » \u001b[22m\u001b[39m \u001b[90mhello\u001b[39m \u001b[90mworld\u001b[39m'
expected = '\u001b[31m\u001b[1m[error] » \u001b[22m\u001b[39m \u001b[90mhello world\u001b[39m'
@acho.transport.store[0].should.be.equal expected

it 'no ouptut messages out of the level', ->
Expand Down

0 comments on commit a7b2c78

Please sign in to comment.