UNPKG

2.07 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.cleanExit = exports.onConfigUpdated = undefined;
7
8var _nightingale = require('nightingale');
9
10var _nightingale2 = _interopRequireDefault(_nightingale);
11
12var _config = require('./config');
13
14var _screen = require('./commands/screen');
15
16var screen = _interopRequireWildcard(_screen);
17
18var _display = require('./commands/display');
19
20var display = _interopRequireWildcard(_display);
21
22var _sound = require('./commands/sound');
23
24var sound = _interopRequireWildcard(_sound);
25
26var _system = require('./commands/system');
27
28var system = _interopRequireWildcard(_system);
29
30var _cron = require('./cron');
31
32var _cron2 = _interopRequireDefault(_cron);
33
34var _flowRuntime = require('flow-runtime');
35
36var _flowRuntime2 = _interopRequireDefault(_flowRuntime);
37
38function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
39
40function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
42const logger = new _nightingale2.default('app:manager');
43
44const update = (config, firstTime = false) => {
45 let _configType = _flowRuntime2.default.object();
46
47 _flowRuntime2.default.param('config', _configType).assert(config);
48
49 (0, _cron2.default)(config);
50 screen.update(config, firstTime);
51 sound.update(config);
52};
53
54process.nextTick(() => {
55 // update time (can fix some SSL certificate issues)
56 system.ntpUpdate();
57 update((0, _config.get)(), true);
58});
59
60const onConfigUpdated = exports.onConfigUpdated = newConfig => {
61 let _newConfigType = _flowRuntime2.default.object();
62
63 _flowRuntime2.default.param('newConfig', _newConfigType).assert(newConfig);
64
65 logger.info('config updated');
66 if (!(0, _config.updateConfig)(newConfig)) return;
67 update(newConfig);
68};
69
70const cleanExit = exports.cleanExit = () => display.stop();
71//# sourceMappingURL=manager.js.map
\No newline at end of file