config env bugfixes
This commit is contained in:
parent
0950a01f96
commit
4301e3003f
6
app.js
6
app.js
|
|
@ -6,6 +6,8 @@ const NTFY = require('./lib/ntfy')
|
|||
const Constants = require('./lib/constants')
|
||||
|
||||
new class LottoAutomation {
|
||||
#configFilename = process.env.LOTTO_AUTOMATION_CONFIG_FILENAME ?? 'Config.json'
|
||||
#configPath = `${process.env.LOTTO_AUTOMATION_CONFIG_DIR ?? __dirname}/${this.#configFilename}`
|
||||
#config = {}
|
||||
|
||||
#_start() {
|
||||
|
|
@ -13,11 +15,11 @@ new class LottoAutomation {
|
|||
setImmediate(this.#_buyLotto.bind(this))
|
||||
}
|
||||
#_loadConfig() {
|
||||
if(!Fs.existsSync(Constants.CONFIG_PATH))
|
||||
if(!Fs.existsSync(this.#configPath))
|
||||
throw new Error('Config.json 파일이 존재하지 않습니다.')
|
||||
|
||||
try {
|
||||
const configString = Fs.readFileSync(Constants.CONFIG_PATH)
|
||||
const configString = Fs.readFileSync(this.#configPath)
|
||||
this.#config = JSON.parse(configString)
|
||||
NTFY.Init(this.#config.ntfyUrl, this.#config.ntfyToken)
|
||||
} catch(e) {
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@ class Constants {
|
|||
'2': '반자동',
|
||||
'3': '자동'
|
||||
}
|
||||
|
||||
static CONFIG_FILENAME = process.env.LOTTO_AUTOMATION_CONFIG_FILENAME ?? 'Config.json'
|
||||
static CONFIG_PATH = `${process.env.LOTTO_AUTOMATION_CONFIG_DIR ?? '.'}/${Constants.CONFIG_FILENAME}`
|
||||
}
|
||||
|
||||
module.exports = Constants
|
||||
Loading…
Reference in New Issue