From 40f5bdcdc82fe692bb9f11bc2b9f4eba9ec85c65 Mon Sep 17 00:00:00 2001 From: gor_down Date: Sat, 30 Nov 2024 18:44:06 -0300 Subject: [PATCH] absolute path --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 455b540..bd2f293 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,10 @@ const fs = require('fs') const irc = require('irc'); -const settings = JSON.parse(fs.readFileSync('settings.json')); +const settings = JSON.parse(fs.readFileSync(rootDir + '/settings.json')); const readline = require('readline') const model = 'user,date,message' +const { dirname } = require('path'); +const rootDir = dirname(require.main.filename); let currentChannel = settings.channels[0] @@ -60,7 +62,7 @@ client.addListener('registered', () => { //////////////////////////////////////////////////////////////// const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; - const filename = 'logs/' + channel + '.csv' + const filename = rootDir + '/logs/' + channel + '.csv' if (!fs.existsSync(filename)){ fs.writeFileSync(filename, model)