|
3 | 3 | */
|
4 | 4 |
|
5 | 5 | var buildDictionary = require('sails-build-dictionary');
|
6 |
| -var async = require('async'); |
7 |
| - |
8 | 6 | var _ = require('lodash');
|
9 | 7 | module.exports = function (sails, dir) {
|
10 |
| - async.auto({ |
11 |
| - |
12 |
| - 'config/*': function loadOtherConfigFiles (cb) { |
13 |
| - buildDictionary.aggregate({ |
| 8 | + buildDictionary.aggregate({ |
14 | 9 | dirname: dir,
|
15 | 10 | exclude: ['locales', 'local.js', 'local.json', 'local.coffee', 'local.litcoffee'],
|
16 | 11 | excludeDirs: /(locales|env)$/,
|
17 | 12 | filter: /(.+)\.(js|json|coffee|litcoffee)$/,
|
18 | 13 | identity: false
|
19 |
| - }, cb) |
20 |
| - }, |
21 |
| - |
22 |
| - 'config/local' : function loadLocalOverrideFile (cb) { |
23 |
| - buildDictionary.aggregate({ |
24 |
| - dirname: dir, |
25 |
| - filter: /local\.(js|json|coffee|litcoffee)$/, |
26 |
| - identity: false |
27 |
| - }, cb); |
28 |
| - }, |
29 |
| - |
30 |
| - 'config/env/**': ['config/local', function loadEnvConfigFolder (cb) { |
31 |
| - var env = sails.config.environment || async_data['config/local'].environment || 'development'; |
32 |
| - buildDictionary.aggregate({ |
33 |
| - dirname: dir + '/env/' + env, |
34 |
| - optional: true, |
35 |
| - filter: /(.+)\.(js|json|coffee|litcoffee)$/, |
36 |
| - identity: false |
37 |
| - }, cb) |
38 |
| - }], |
39 |
| - |
40 |
| - 'config/env/*' : ['config/local', function loadEnvConfigFile (cb, async_data) { |
41 |
| - var env = sails.config.environment || async_data['config/local'].environment || 'development'; |
42 |
| - buildDictionary.aggregate({ |
43 |
| - dirname: dir + '/env', |
44 |
| - filter: new RegExp("^" + env + "\\.(js|json|coffee|litcoffee)$"), |
45 |
| - optional: true, |
46 |
| - identity: false |
47 |
| - }, cb); |
48 |
| - }] |
49 |
| - |
50 |
| - }, function (err, async_data) { |
51 |
| - |
52 |
| - if (err) { throw err; } |
53 |
| - |
54 |
| - // Merge the configs, with env/*.js files taking precedence over others, and local.js |
55 |
| - // taking precedence over everything |
56 |
| - var configs = _.merge( |
57 |
| - async_data['config/*'], |
58 |
| - async_data['config/env/**'], |
59 |
| - async_data['config/env/*'], |
60 |
| - async_data['config/local'] |
61 |
| - ); |
62 |
| - |
63 |
| - sails.config = _.merge(configs, sails.config, function (a, b) { |
64 |
| - if (_.isArray(a)) { |
65 |
| - return a.concat(b); |
66 |
| - } |
| 14 | + }, function (err, configs) { |
| 15 | + sails.config = _.merge(configs, sails.config, function (a, b) { |
| 16 | + if (_.isArray(a)) { |
| 17 | + return a.concat(b); |
| 18 | + } |
| 19 | + }); |
67 | 20 | });
|
68 |
| - |
69 |
| - }); |
70 |
| - |
71 | 21 | };
|
0 commit comments