UNPKG

1.7 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.updateConfig = updateConfig;
7exports.getTime = getTime;
8exports.get = get;
9
10var _configstore = require('configstore');
11
12var _configstore2 = _interopRequireDefault(_configstore);
13
14var _deepEqual = require('deep-equal');
15
16var _deepEqual2 = _interopRequireDefault(_deepEqual);
17
18var _argv = require('./argv');
19
20var _networkInterface = require('./utils/networkInterface');
21
22var _networkInterface2 = _interopRequireDefault(_networkInterface);
23
24var _package = require('../package.json');
25
26function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
28// import availableDisplays from './utils/availableDisplays';
29
30const defaultConfig = () => {
31 const networkInterface = (0, _networkInterface2.default)();
32 return {
33 display: 'chromium',
34 url: `${_argv.serverHost}/no-config?ip=${networkInterface && networkInterface.ip}`
35 // url: `http://localhost${webPort === 80 ? '' : `:${webPort}`}/no-config`,
36 };
37};
38
39const configStore = new _configstore2.default(_package.name, defaultConfig());
40let config = configStore.all;
41
42if (!config || !config.display || config.url && config.url.startsWith('undefined')) {
43 config = defaultConfig();
44}
45
46function save() {
47 configStore.all = config;
48}
49
50// if (availableDisplays.indexOf(config.display) === -1) {
51// config.display = 'chromium';
52// save();
53// }
54
55function updateConfig(newConfig) {
56 if ((0, _deepEqual2.default)(config, newConfig)) {
57 return false;
58 }
59
60 config = newConfig;
61 save();
62 return true;
63}
64
65function getTime() {
66 return config.time;
67}
68
69function get() {
70 return config;
71}
72//# sourceMappingURL=config.js.map
\No newline at end of file