- Removing unused code
* Fixing issue with json integers being mis represented
This commit is contained in:
parent
be0dc39042
commit
3472e4d7c7
@ -1,14 +1,12 @@
|
|||||||
const { ArgumentParser } = require('argparse')
|
const { ArgumentParser } = require('argparse')
|
||||||
const fs = require('fs').promises
|
const fs = require('fs').promises
|
||||||
const syncFs = require('fs')
|
const syncFs = require('fs')
|
||||||
|
const JSONBig = require('json-bigint')({storeAsString: true})
|
||||||
// required because freechat by default uses i64/u64 in json payloads
|
|
||||||
// timestamps will get especially rekt'd if we don't parse things correctly
|
|
||||||
const JSONBig = require('json-bigint')
|
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
* TODO: change .data out for something not stupid
|
||||||
* @param {String} path path to config on startup
|
* @param {String} path path to config on startup
|
||||||
* @param {Object} data Contains actual config data
|
* @param {Object} data Contains actual config data
|
||||||
*/
|
*/
|
||||||
@ -39,12 +37,13 @@ exports.from_cli_parser = function(parser) {
|
|||||||
let ret = new Config(path, {})
|
let ret = new Config(path, {})
|
||||||
|
|
||||||
// Allow errors from here to bubble up instead of handling them
|
// Allow errors from here to bubble up instead of handling them
|
||||||
|
|
||||||
fs.readFile(path).then(file => {
|
fs.readFile(path).then(file => {
|
||||||
const json = JSONBig.parse(file)
|
const json = JSONBig.parse(file)
|
||||||
|
ret.data['servers'] = []
|
||||||
|
|
||||||
for(const key of Object.keys(json)) {
|
// TODO: redo this so its let 'yolo'
|
||||||
ret.data[key] = json[key]
|
for(const serv of json['servers']) {
|
||||||
|
ret.data['servers'].push(serv)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => console.error(err))
|
.catch(err => console.error(err))
|
||||||
@ -52,26 +51,3 @@ exports.from_cli_parser = function(parser) {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the config with the new object data
|
|
||||||
* Called from node's main process
|
|
||||||
*
|
|
||||||
* @param {Config} config new config data to write
|
|
||||||
* @param {String} path | set to 'default' if we're using $HOME/.config/freechat/config.json
|
|
||||||
* Set this to anything else to write changes to that specified path
|
|
||||||
*/
|
|
||||||
exports.update_file = function(config, path='default') {
|
|
||||||
if (path == 'default') {
|
|
||||||
path = `${process.env.HOME || process.env.USERPROFILE}/.config/freechat/config.json`
|
|
||||||
} else {
|
|
||||||
path = path
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = JSON.stringify(config, null, 2)
|
|
||||||
fs.writeFile(path, data, function(err) {
|
|
||||||
if(err) { console.error(err) }
|
|
||||||
else { console.log('fine') }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,10 +54,4 @@ export class Event {
|
|||||||
|
|
||||||
return new Message(mid, time, content, content_type, uid, uname, cid)
|
return new Message(mid, time, content, content_type, uid, uname, cid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets up the inner channel data
|
|
||||||
private _channel(obj: Object) : Channel|null {
|
|
||||||
// todo: still require some testing to verify event data is appropriate
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user