From 6801afff0615173ada3e85f781983b039d5bd2ce Mon Sep 17 00:00:00 2001 From: kuritka Date: Wed, 17 Mar 2021 18:10:09 +0100 Subject: [PATCH] fix issue where logger in GithubAction printed messges faster than fmt.Println --- README.md | 2 +- cmd/inject.go | 10 ++++++++-- cmd/root.go | 6 ------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 74389d7..d7daf39 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ create `.licignore` in project root Install and run **GOLIC** ```shell # GO 1.16 -go install github.com/AbsaOSS/golic@v0.4.3 +go install github.com/AbsaOSS/golic@v0.4.4 golic inject -c="2021 MyCompany ltd." ``` diff --git a/cmd/inject.go b/cmd/inject.go index b77f752..e7c2d86 100644 --- a/cmd/inject.go +++ b/cmd/inject.go @@ -18,6 +18,7 @@ Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic package cmd import ( + "github.com/enescakir/emoji" "net/url" "os" @@ -36,15 +37,20 @@ var injectCmd = &cobra.Command{ if _, err := os.Stat(injectOptions.LicIgnore); os.IsNotExist(err) { logger.Error().Msgf("invalid license path '%s'",injectOptions.LicIgnore) _ = cmd.Help() - os.Exit(0) + os.Exit(1) } if _,err := url.Parse(injectOptions.ConfigURL); err != nil { logger.Error().Msgf("invalid config.yaml url '%s'",injectOptions.ConfigURL) _ = cmd.Help() - os.Exit(0) + os.Exit(1) } i := inject.New(ctx, injectOptions) exitCode = Command(i).MustRun() + if exitCode == 0 { + logger.Info().Msgf("%s%s%s done", emoji.Rocket, emoji.Rocket, emoji.Rocket) + } else { + logger.Info().Msgf("%s exit", emoji.FaceScreamingInFear) + } }, } diff --git a/cmd/root.go b/cmd/root.go index 413cd69..56bdec8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -21,7 +21,6 @@ package cmd import ( "context" "fmt" - "github.com/enescakir/emoji" "os" "github.com/AbsaOSS/golic/utils/log" @@ -48,11 +47,6 @@ var rootCmd = &cobra.Command{ } }, PersistentPostRun: func(cmd *cobra.Command, args []string) { - if exitCode == 0 { - logger.Info().Msgf("%s%s%s done", emoji.Rocket, emoji.Rocket, emoji.Rocket) - } else { - logger.Info().Msgf("%s exit", emoji.FaceScreamingInFear) - } os.Exit(exitCode) }, }