Skip to content

Commit

Permalink
adds environment specific methods
Browse files Browse the repository at this point in the history
  • Loading branch information
minibikini committed Feb 11, 2014
1 parent 1951a9f commit 5233ca8
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions lib/AppSpine.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,32 @@ module.exports = class AppSpine extends EventEmitter2
super @config.emitter
@setupLogger()

isDev: -> @getEnv() is 'development'

configure: (env, fn) -> fn() if @getEnv() is env
getEnvironment: ->
@config.env or process.env.NODE_ENV or 'development'

getEnv: ->
process.env.NODE_ENV or 'development'
@getEnvironment()

isDevelopment: ->
@getEnvironment() is 'development'

isDev: ->
@isDevelopment()

isTesting: ->
@getEnvironment() is 'testing'

isStaging: ->
@getEnvironment() is 'staging'

isProduction: ->
@getEnvironment() is 'production'

isProd: ->
@isProduction()

configure: (env, fn) ->
fn() if @getEnvironment() is env

require: (path) ->
require(path)(@)
Expand All @@ -33,8 +53,6 @@ module.exports = class AppSpine extends EventEmitter2
@config.logger.format ?= "[{{title}}] {{timestamp}} ({{file}}:{{line}}): {{message}}"
@config.logger.filters ?= loggerColorFilters
@config.logger.dateformat ?= "HH:MM:ss"

unless @config.logger.level?
@config.logger.level = if @isDev() then 'log' else 'warn'
@config.logger.level ?= if @isDev() then 'log' else 'warn'

@logger = tracer.colorConsole @config.logger

0 comments on commit 5233ca8

Please sign in to comment.