Skip to content

Commit

Permalink
Separate align from diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jan 25, 2016
1 parent 8b27e1a commit 134fa13
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
21 changes: 12 additions & 9 deletions lib/Default.coffee
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use strict'

chalk = require 'chalk'
ms = require 'pretty-ms'
humanizeMs = require 'ms'
CONST = require './Constants'
formatUtil = require 'format-util'

module.exports =
print: ->
for type of @types
@transport @generateMessage type, message for message in @messages[type]

outputMessage: (message) -> message
outputType: (type, diff = '') ->
if @align and not @diff then "#{type}#{diff}\t" else "#{type}#{diff} "
outputType: (type) ->
align = if @align then "\t" else " "
"#{type}#{align}"

transport: console.log

Expand All @@ -28,16 +28,19 @@ module.exports =

if @diff
if @diff[type]
diff = new Date() - @diff[type]
diff = if diff > CONST.MIN_DIFF_MS then ms diff else "#{diff}ms"
@diff[type] = new Date()
diff = humanizeMs(new Date() - @diff[type])
diff = " +#{diff}"
@diff[type] = new Date()
else
@diff[type] = new Date()
diff = " +0ms"

messageType = @outputType keyword, diff
messageType = @outputType keyword
messageType = @colorize colorType, messageType
messageType + message

output = messageType + message
output += @colorize colorType, diff if diff
output

generateTypeMessage: (type) ->
(message...) ->
Expand Down
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
"version": "2.4.2",
"main": "./index.js",
"author": {
"email": "[email protected]",
"name": "Kiko Beats",
"email": "[email protected]",
"url": "https://github.com/Kikobeats"
},
"repository": "Kikobeats/acho",
"repository": {
"type": "git",
"url": "git+https://github.com/kikobeats/acho.git"
},
"bugs": {
"url": "https://github.com/Kikobeats/acho/issues"
},
Expand All @@ -19,11 +22,11 @@
"logging"
],
"dependencies": {
"chalk": "latest",
"coffee-script": "latest",
"existential-assign": "latest",
"format-util": "latest",
"pretty-ms": "latest"
"chalk": "~1.1.1",
"coffee-script": "~1.10.0",
"existential-assign": "~1.2.2",
"format-util": "1.0.3",
"ms": "~0.7.1"
},
"devDependencies": {
"browserify": "latest",
Expand Down

0 comments on commit 134fa13

Please sign in to comment.