-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.js
38 lines (34 loc) · 1.08 KB
/
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
const fs = require('fs');
const path = require('path');
let config = null;
function getConfig() {
if (config === null) {
try {
const _configFileName = `${process?.env?.CARBONE_AST_CONFIG ?? 'config.json'}`
const _path = process?.env?.CARBONE_AST_CONFIG_PATH ? path.join(process.env.CARBONE_AST_CONFIG_PATH, _configFileName) : path.join(__dirname, '..', 'config', _configFileName);
config = JSON.parse(fs.readFileSync(_path, 'utf8'));
} catch (e) {
config = {};
}
}
if (process?.env?.AZURE_STORAGE_ACCOUNT && process?.env?.AZURE_STORAGE_KEY) {
config.storageCredentials = {
accountName: process.env.AZURE_STORAGE_ACCOUNT,
accountKey: process.env.AZURE_STORAGE_KEY
}
}
if (process?.env?.CONTAINER_RENDERS) {
config.rendersContainer = process.env.CONTAINER_RENDERS
}
if (process?.env?.CONTAINER_TEMPLATES) {
config.templatesContainer = process.env.CONTAINER_TEMPLATES
}
return config;
}
function setConfig(newConfig) {
config = newConfig;
}
module.exports = {
getConfig,
setConfig
};