nl_tokens: Get a configuration based on options .
pl_tokens: function get ( options , config ) { options = options || found config = config || { } // Load options. var dir = options . dir || found . dir || 'config' var env = options . env || found . env || 'staging' var base = options . base || found . base || 'base' // Allow many "env" values. var key = env . toLowerCase ( ) . replace ( / ^([gro]|ca) / , 'p' ) // gamma, release, one, canary -> "production". . replace ( / ^(sa|[al]) / , 'd' ) // sandbox, alpha, local -> "development". . replace ( / ^[qtbcij] / , 's' ) [ 0 ] // qa, test, beta, ci, jenkins -> "staging". // Coerce to an expected environment. var environment = map [ key ] || map [ key = 's' ] config . env = env config . environment = environment config . isDebug = / de?bu?g / i . test ( env ) config . isDevelopment = ( key === 'd' ) config . isStaging = ( key === 's' ) config . isProduction = ( key === 'p' ) // Load files. hide ( config , 'load' , load ) // Load configuration from files. config . load ( dir , base ) config . load ( dir , <mask> ) // Load any matching sub-environments. var subEnvironments = config . subEnvironments if ( subEnvironments && subEnvironments . indexOf ( env ) > - 1 ) { config . load ( dir , env ) } return config }