mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
sending tracking information (#116)
* Ability to send tracking information
This commit is contained in:
committed by
GitHub
parent
3d59c0096d
commit
8f91267b5d
19
lib/utils.js
19
lib/utils.js
@@ -2,6 +2,7 @@ import {dirname} from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {readFile} from 'fs/promises';
|
||||
import {createHash} from 'crypto';
|
||||
import {DEFAULT_CONFIG} from './defaultConfig.js';
|
||||
|
||||
function isOneOf(word, arr) {
|
||||
if (arr == null || arr.length === 0) {
|
||||
@@ -52,7 +53,23 @@ function buildHash(...inputs) {
|
||||
.digest('hex');
|
||||
}
|
||||
|
||||
const config = JSON.parse(await readFile(new URL('../conf/config.json', import.meta.url)));
|
||||
let config = {};
|
||||
export async function readConfigFromStorage(){
|
||||
return JSON.parse(await readFile(new URL('../conf/config.json', import.meta.url)));
|
||||
}
|
||||
|
||||
export async function refreshConfig(){
|
||||
try {
|
||||
config = await readConfigFromStorage();
|
||||
//backwards compatability...
|
||||
config.analyticsEnabled ??= null;
|
||||
config.demoMode ??= false;
|
||||
} catch (error) {
|
||||
config = {...DEFAULT_CONFIG};
|
||||
console.error('Error reading config file', error);
|
||||
}
|
||||
}
|
||||
await refreshConfig();
|
||||
|
||||
export {isOneOf};
|
||||
export {nullOrEmpty};
|
||||
|
||||
Reference in New Issue
Block a user