提交 1bf63dd76074086f51440acae184ab69d5f5f062

作者 Bruno Bernardino
1 个父辈 d9a67a20

Allow boot/local.js file

It seems there's something incomplete about #15 as there's no way local.js is being included.

This should fix it.
正在显示 1 个修改的文件 包含 16 行增加5 行删除
@@ -11,17 +11,28 @@ exports = module.exports = function(config, local) { @@ -11,17 +11,28 @@ exports = module.exports = function(config, local) {
11 11
12 var env = process.env.NODE_ENV || 'development' 12 var env = process.env.NODE_ENV || 'development'
13 13
14 - if (!_.isObject(config[env]))  
15 - throw new Error(util.format('Unknown environment %s', env))  
16 -  
17 if (!_.isObject(local)) 14 if (!_.isObject(local))
18 local = {} 15 local = {}
19 16
20 - mergeDefaults(settings, local, config[env], config.defaults) 17 + mergeDefaults(config, local)
  18 +
  19 + if (!_.isObject(config[env]))
  20 + throw new Error(util.format('Unknown environment %s', env))
  21 +
  22 + mergeDefaults(settings, config[env], config.defaults)
21 23
22 return settings 24 return settings
23 25
24 } 26 }
25 27
26 exports['@singleton'] = true 28 exports['@singleton'] = true
27 -exports['@require'] = [ 'config' ] 29 +exports['@require'] = ['config']
  30 +
  31 +var fs = require('fs')
  32 +var path = require('path')
  33 +var localPath = path.join(__dirname, '..', '..', '..', '..' ,'boot', 'local.js')
  34 +
  35 +// Include local.js if it exists at boot/local.js
  36 +if (fs.existsSync(localPath)) {
  37 + exports['@require'].push('local')
  38 +}
注册登录 后发表评论