From 4301e3003fb85fb118433f4650e0ddae94bd499c Mon Sep 17 00:00:00 2001 From: "hojin.jeong" Date: Mon, 25 Aug 2025 16:23:30 +0900 Subject: [PATCH] config env bugfixes --- app.js | 10 ++++++---- lib/constants.js | 3 --- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index aac013e..dbdb090 100644 --- a/app.js +++ b/app.js @@ -6,18 +6,20 @@ const NTFY = require('./lib/ntfy') const Constants = require('./lib/constants') new class LottoAutomation { - #config = {} + #configFilename = process.env.LOTTO_AUTOMATION_CONFIG_FILENAME ?? 'Config.json' + #configPath = `${process.env.LOTTO_AUTOMATION_CONFIG_DIR ?? __dirname}/${this.#configFilename}` + #config = {} #_start() { this.#_loadConfig() 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,7 +38,7 @@ new class LottoAutomation { const successMessageArr = [ `구매 성공`, `ROUND: ${buyResult.round}`, - `COST : ${buyResult.cost}`, + `COST: ${buyResult.cost}`, ] successMessageArr.push( ...buyResult.numbers.map(numberStr => { diff --git a/lib/constants.js b/lib/constants.js index 9ebbcd0..700db74 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -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 \ No newline at end of file