flush logs on cmd failure (#1338)

## Description

The secondary scripts in corso (factory, purge, etc) are not currently flushing their logs if an error occurrs since os.Exit(1) kills the current process without alloting time for deferred funcs to run.

## Type of change

- [x] 🐛 Bugfix

## Issue(s)

* #902

## Test Plan

- [x] 💚 E2E
This commit is contained in:
Keepers 2022-10-27 16:57:05 -06:00 committed by GitHub
parent b7a7b22f94
commit a31b01458c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 0 deletions

View File

@ -79,6 +79,7 @@ func main() {
addOneDriveCommands(oneDriveCmd)
if err := factoryCmd.ExecuteContext(ctx); err != nil {
logger.Flush(ctx)
os.Exit(1)
}
}

View File

@ -63,6 +63,7 @@ func main() {
cobra.CheckErr(getCmd.MarkPersistentFlagRequired("category"))
if err := getCmd.ExecuteContext(ctx); err != nil {
logger.Flush(ctx)
os.Exit(1)
}
}

View File

@ -88,6 +88,7 @@ func main() {
purgeCmd.AddCommand(oneDriveCmd)
if err := purgeCmd.ExecuteContext(ctx); err != nil {
logger.Flush(ctx)
os.Exit(1)
}
}