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)