-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigTransform.js
33 lines (30 loc) · 1.26 KB
/
configTransform.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
/*
********************************************
Copyright © 2021 Agora Lab, Inc., all rights reserved.
AppBuilder and all associated components, source code, APIs, services, and documentation
(the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
Use without a license or in violation of any license terms and conditions (including use for
any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
information visit https://appbuilder.agora.io.
*********************************************
*/
let jsonFile = require('./config.json');
let PREFIX = '$config';
let config = {};
Object.keys(jsonFile).map(key => {
config[`${PREFIX}.${key}`] = jsonFile[key];
});
//find any missing config
const defaultConfig = require('./defaultConfig');
const filteredArray = Object.keys(defaultConfig).filter(
value => !Object.keys(jsonFile).includes(value),
);
//add missing config with default value
if (filteredArray && filteredArray?.length) {
//console.error('config.json missing ', filteredArray);
filteredArray.forEach(i => {
config[`${PREFIX}.${i}`] = defaultConfig[i];
});
}
module.exports = config;