First commit
This commit is contained in:
23
src/core/config.js
Normal file
23
src/core/config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import fs from "fs"
|
||||
|
||||
let _configFile = "config.json"
|
||||
if(process.argv[2]) _configFile = process.argv[2]
|
||||
|
||||
let _config = null
|
||||
|
||||
const load = () => {
|
||||
if(! fs.existsSync(_configFile)) {
|
||||
throw new Error('Config file not found')
|
||||
}
|
||||
_config = JSON.parse(fs.readFileSync(_configFile))
|
||||
}
|
||||
|
||||
if(! _config) load()
|
||||
|
||||
const get = () => {
|
||||
return structuredClone(_config)
|
||||
}
|
||||
|
||||
export default {
|
||||
get,
|
||||
}
|
||||
Reference in New Issue
Block a user