From 8b1fa24eed369bef44f4a1d99256962e2d2d9645 Mon Sep 17 00:00:00 2001 From: alexandershpak Date: Wed, 20 Feb 2019 15:35:34 +0300 Subject: [PATCH] bug(fix): Change order of controller's log files update postinstall script for version less 1.0.37 (ENG-584) --- scripts/postinstall.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 9d8c5c076..98e21ad49 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -15,6 +15,7 @@ const os = require('os'); const execSync = require('child_process').execSync; const fs = require('fs'); const semver = require('semver'); +const config = require('../src/config'); const currentVersion = require('../package').version; const {restoreDBs, restoreConfigs, INSTALLATION_VARIABLES_FILE} = require('./util'); @@ -41,6 +42,10 @@ function postinstall() { console.log('upgrading from version <= 1.0.30 :'); updateEncryptionMethod(); } + if (semver.satisfies(prevVersion, '<=1.0.37')) { + console.log('upgrading from version <= 1.0.37 :'); + updateLogName(); + } fs.unlinkSync(INSTALLATION_VARIABLES_FILE); } catch (e) { @@ -151,6 +156,24 @@ function updateEncryptionMethod() { updateEncryptionMethodForEmailService(prodConfig, decryptTextVer30); } +function updateLogName() { + console.log(' updating log name in '); + const dirname = config.get('Service:LogsDirectory') + + if (fs.existsSync(dirname)) { + fs.readdirSync(dirname).forEach(file => { + const path = dirname + '/' + file + if (fs.existsSync(path)) { + fs.unlinkSync(path, function(err) { + if (err) return console.log(err); + console.log('log deleted successfully'); + }) + } + }); + } + +} + module.exports = { postinstall: postinstall }; \ No newline at end of file