bug(cmd): Ensure RunShutdownFuncs is called when an early error occurs (#2333)

* bug(cmd): Ensure RunShutdownFuncs is called when an early error occurs
This commit is contained in:
Louis Ruch authored and GitHub committed 2022-08-08 09:13:47 -07:00
1 parent 4d966c8eb4
commit dcccaf1bcf
4 files changed
+22 -12

No files matched your search

+6
View File
@@ -177,6 +177,12 @@ func (c *InitCommand) Run(args []string) (retCode int) {
return result
}
defer func() {
if err := c.RunShutdownFuncs(); err != nil {
c.UI.Error(fmt.Errorf("Error running shutdown tasks: %w", err).Error())
}
}()
if c.configWrapperCleanupFunc != nil {
defer func() {
if err := c.configWrapperCleanupFunc(); err != nil {