-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
49 lines (37 loc) · 848 Bytes
/
extension.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
41
42
43
44
45
46
47
48
49
'use strict';
var fs = require('fs');
var defaultConfig = {
vmix: {
enabled: false,
ip: '127.0.0.1',
port: 8088
},
obs: {
enabled: false,
ip: '127.0.0.1',
port: 4444
}
};
var config;
module.exports = function (nodecg) {
// Default Config
if (!nodecg.bundleConfig) {
fs.writeFile('cfg/nodecg-switcher.json', JSON.stringify(defaultConfig), function (err) {
if (err) throw err;
nodecg.log.info('Saved default config');
});
config = defaultConfig;
} else {
config = nodecg.bundleConfig;
}
var configRep = nodecg.Replicant('config', config);
configRep.on('change', function (oldVal, newVal) {
if (oldVal !== newVal) {
config = newVal;
fs.writeFile('cfg/nodecg-switcher.json', JSON.stringify(config), function (err) {
if (err) throw err;
nodecg.log.info('Saved config');
});
}
});
};