From b3e66d5a8392c44ce69b1258ff948dac1c8e2704 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 7 Jun 2020 10:45:41 +0200 Subject: [PATCH] fixed command line anonymization --- src/anonymize.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/anonymize.js b/src/anonymize.js index fdcc6d110..4599f3ac6 100644 --- a/src/anonymize.js +++ b/src/anonymize.js @@ -1,12 +1,24 @@ const backupService = require('./services/backup'); +const sqlInit = require('./services/sql_init'); +require('./entities/entity_constructor'); -backupService.anonymize().then(resp => { - if (resp.success) { - console.log("Anonymization failed."); +sqlInit.dbReady.then(async () => { + try { + console.log("Starting anonymization..."); + + const resp = await backupService.anonymize(); + + if (resp.success) { + console.log("Anonymized file has been saved to: " + resp.anonymizedFilePath); + + process.exit(0); + } else { + console.log("Anonymization failed."); + } } - else { - console.log("Anonymized file has been saved to: " + resp.anonymizedFilePath); + catch (e) { + console.error(e.message, e.stack); } - process.exit(0); + process.exit(1); });