forked from chrisspiegl/ControlThemAll
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControllerConfig.js
More file actions
32 lines (23 loc) · 831 Bytes
/
Copy pathControllerConfig.js
File metadata and controls
32 lines (23 loc) · 831 Bytes
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
import fs from 'node:fs'
import merge from 'deepmerge'
import YAML from 'yaml'
export class ControllerConfig {
constructor() {
this.config = undefined
}
async getConfig() {
if (this.config) {
console.log('Config already loaded and just returning!')
return this.config
}
console.log('Loading the configuration from the YAML files')
const configDefault = YAML.parse(fs.readFileSync('./config.default.yaml', 'utf8'))
const configUser = YAML.parse(fs.readFileSync('./config.user.yaml', 'utf8'))
this.config = merge(configDefault, configUser)
// Console.log(`config:`, config)
this.config.dve.stateMain = { ...this.config.dve.stateDefault }
this.config.dve.stateCurrent = { ...this.config.dve.stateDefault }
return this.config
}
}
export default ControllerConfig