Skip to content

Commit 9674514

Browse files
committed
Merge pull request #6 from leeroybrun/revert-5-master
Revert "Update config loader to include env configs" Config should not be loaded asynchronously, otherwise Sails will start initializing hooks and other things while config is not fully loaded. We need to do more tests on this.
2 parents 4d3084d + 35c5cb5 commit 9674514

File tree

1 file changed

+7
-57
lines changed

1 file changed

+7
-57
lines changed

libs/config.js

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,19 @@
33
*/
44

55
var buildDictionary = require('sails-build-dictionary');
6-
var async = require('async');
7-
86
var _ = require('lodash');
97
module.exports = function (sails, dir) {
10-
async.auto({
11-
12-
'config/*': function loadOtherConfigFiles (cb) {
13-
buildDictionary.aggregate({
8+
buildDictionary.aggregate({
149
dirname: dir,
1510
exclude: ['locales', 'local.js', 'local.json', 'local.coffee', 'local.litcoffee'],
1611
excludeDirs: /(locales|env)$/,
1712
filter: /(.+)\.(js|json|coffee|litcoffee)$/,
1813
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+
});
6720
});
68-
69-
});
70-
7121
};

0 commit comments

Comments
 (0)