-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathget-core-config.js
39 lines (34 loc) · 1022 Bytes
/
get-core-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
/* eslint global-require: "off" */
/* eslint no-console: ["error", { allow: ["log"] }] */
const path = require('path');
let config = require('./build-config.js');
// Overwrite with local config
try {
// eslint-disable-next-line
const customConfig = require('./build-config-custom.js');
config = Object.assign({}, config, customConfig);
} catch (err) {
// No local config
}
let logged = false;
function getConfig() {
const args = process.argv;
let configArgIndex;
let configPath;
args.forEach((arg, argIndex) => {
if (arg === '--config') configArgIndex = argIndex;
});
if (configArgIndex && args[configArgIndex + 1]) {
configPath = path.resolve(args[configArgIndex + 1]);
}
if (configPath) {
const overwriteConfig = require(configPath); // eslint-disable-line
config = Object.assign({}, config, overwriteConfig);
if (!logged) {
console.log(`Building using custom config from ${configPath}`);
}
logged = true;
}
return config;
}
module.exports = getConfig;