diff --git a/index.js b/index.js index b753f8f..6acdf57 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,7 @@ let configs = { assets: config.get('assets'), sounds: config.get('sounds'), settings: config.get('settings'), + elogs: config.get('elogs'), } // Start simulation. diff --git a/src/simulator.js b/src/simulator.js index 5ddc65c..1b994ff 100644 --- a/src/simulator.js +++ b/src/simulator.js @@ -10,7 +10,7 @@ class Simulator { constructor(configs) { this.configs = configs; - + // Read assets ids from configs this.assetIds = configs.assets.ids; @@ -37,19 +37,20 @@ class Simulator { } _manageLogs(callback) { - fs.readdir('logs', (err, files) => { + try { + fs.unlinkSync(path.join('logs/', 'error_'+this.configs.elogs.name+'.log'), err => { if (err) throw err; - for (const file of files) { - fs.unlinkSync(path.join('logs', file), err => { - if (err) throw err; - }); - } + }); + fs.unlinkSync(path.join('logs/', 'simulator_'+this.configs.elogs.name+'.log'), err => { + if (err) throw err; + }); + } catch(e) { console.log(e) } fs.openSync('./logs/simulator_'+this.configs.elogs.name+'.log', 'w'); utils.writeLog('START'); utils.writeLog(`process.env["NODE_CONFIG_DIR"]: ${process.env["NODE_CONFIG_DIR"]}`); fs.openSync('./logs/error_'+this.configs.elogs.name+'.log', 'w'); - }); + return callback(); }