fix: refactor process.exit(1) calls to run after logger flushes

https://stackoverflow.com/questions/18771707/how-to-flush-winston-logs
This commit is contained in:
tachi-seeds
2022-06-22 11:55:16 +01:00
parent eced221664
commit c0d5d40944
28 changed files with 114 additions and 80 deletions
+10 -4
View File
@@ -67,15 +67,21 @@ if (require.main === module) {
ValidateCollection(options.collection as Databases)
.then(() => process.exit(0))
.catch((err: unknown) => {
logger.error(`Failed to validate collection ${options.collection}?`, { err });
process.exit(1);
logger.error(
`Failed to validate collection ${options.collection}?`,
{ err },
() => {
process.exit(1);
}
);
});
} else {
ValidateAllCollections()
.then(() => process.exit(0))
.catch((err: unknown) => {
logger.error(`Failed to validate all collections?`, { err });
process.exit(1);
logger.error(`Failed to validate all collections?`, { err }, () => {
process.exit(1);
});
});
}
}