This commit is contained in:
TheNetsky
2023-10-26 15:31:35 +02:00
parent e195f973cd
commit c2b68faa74
20 changed files with 1150 additions and 988 deletions

35
src/util/Load.ts Normal file
View File

@@ -0,0 +1,35 @@
import fs from 'fs'
import path from 'path'
import { Account } from '../interface/Account'
import { Config } from '../interface/Config'
export function loadAccounts(): Account[] {
try {
let file = 'accounts.json'
// If dev mode, use dev account(s)
if (process.argv.includes('-dev')) {
file = 'accounts.dev.json'
}
const accountDir = path.join(__dirname, '../', file)
const accounts = fs.readFileSync(accountDir, 'utf-8')
return JSON.parse(accounts)
} catch (error) {
throw new Error(error as string)
}
}
export function loadConfig(): Config {
try {
const configDir = path.join(__dirname, '../', 'config.json')
const config = fs.readFileSync(configDir, 'utf-8')
return JSON.parse(config)
} catch (error) {
throw new Error(error as string)
}
}