forked from botwillacceptanything/botwillacceptanything
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.js
40 lines (32 loc) · 987 Bytes
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(function () {
'use strict';
var define = require('amdefine')(module);
var fs = require('fs');
var fse = require('fs-extra');
var deps = [
'./configs/custom.js',
'lodash',
'./configs/template.js',
];
var err;
// If configs/custom.js doesn't exist right now, copy the template.
if (fs.existsSync('./configs/custom.js') === false) {
fse.copySync('./configs/template.js', './configs/custom.js');
}
// Update the loader and then prepare the config for merging.
prepareConfig();
function prepareConfig() {
var exists = fs.existsSync('./configs/' + process.env.BUILD_ENVIRONMENT + '.js');
if (exists === true) {
deps.push('./configs/' + process.env.BUILD_ENVIRONMENT + '.js');
}
mergeConfig();
}
function mergeConfig() {
define(deps, function (config, _, template, env) {
if (typeof env === 'undefined') { env = {}; }
_.merge(template, config, env);
module.exports = template;
});
}
}());