Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jan 2, 2016
1 parent 6376eed commit a0af84e
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions lib/Bumped.logger.coffee
Expand Up @@ -4,28 +4,31 @@ Acho = require 'acho'
DEFAULT = require './Bumped.default'
existsAssign = require 'existential-assign'

module.exports = (opts) ->
opts = existsAssign DEFAULT.logger, opts
logger = Acho opts
optsDefault =
lineBreak: true

# Extending with error handler
logger.errorHandler = (err, opts, cb) ->
optsDefault = lineBreak: true
errorHandler = (err, opts, cb) ->
if (arguments.length is 2)
cb = opts
opts = optsDefault
else
opts = opts or optsDefault
cb = cb or ->

if (arguments.length is 2)
cb = opts
opts = optsDefault
else
opts = opts or optsDefault
cb = cb or ->
return cb err if @level is 'silent'

printErrorMessage = (err) => @error err.message or err
printErrorMessage = (err) => @error err.message or err
process.stdout.write '\n' if opts.lineBreak

process.stdout.write '\n' if opts.lineBreak
err = if Array.isArray(err) then err else [err]
err = if Array.isArray(err) then err else [err]
err.forEach printErrorMessage

err.forEach printErrorMessage
@keyword = DEFAULT.logger.keyword
cb err
# TODO: Necessary?
@keyword = DEFAULT.logger.keyword
cb err

module.exports = (opts) ->
opts = existsAssign DEFAULT.logger, opts
logger = Acho opts
logger.errorHandler = errorHandler
logger

0 comments on commit a0af84e

Please sign in to comment.