 @warn = @w = createWriter WARN, styler.warn
 
 @error = @e = do ->
-    errorWriter = createWriter ERROR, styler.error, process.stderr
+    errorWriter = createWriter ERROR, styler.error, stderr
     (msg, end = yes, exitCode = 1) ->
         ret = errorWriter msg
-        process.exit exitCode if end is yes
+        exit exitCode if end is yes
         ret
 
 

    .updateInfo("My name is joan")
    .endLine()

process.stdout.write "Shouldn't appear"; @eraseLine()

@error("This ends with error code 2", true, 2)
@info("Should'nt be printed")

_ = require 'lodash'
assert = require 'assert'
{ clearLine, cursorTo } = require 'readline'

styler = require './styler'
{ verbose } = require './cli'

module.exports = @

# Alias
{ stdout, stderr, exit } = process

# Constants
[INFO,WARN,ERROR,VERBOSE] = TAGS = ["INFO", "WARN", "ERROR", "VERBS"]
LEFT_MARGIN = _.maxBy(TAGS, _.size).length + 1
TAG_INDICATOR = ': '
LEFT_PADSTRING_LONG_LINES = _.repeat(" ", LEFT_MARGIN + TAG_INDICATOR.length)
MAX_COLS_PER_LINE = Math.max 10, stdout.columns - LEFT_PADSTRING_LONG_LINES.length - 1

# Private methods
tag = (txt, style) -> style(_.padEnd(txt, LEFT_MARGIN)) + TAG_INDICATOR
