From 02331febb9e2ada9dc4ae9b0b51f4c74679b8626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A1=D1=8B=D1=81?= =?UTF-8?q?=D0=BE=D0=B5=D0=B2?= Date: Sun, 10 Dec 2023 19:26:25 +0800 Subject: [PATCH] Updates nil check for tests --- pkg/command/commands.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/command/commands.go b/pkg/command/commands.go index e13d2e5..af00787 100644 --- a/pkg/command/commands.go +++ b/pkg/command/commands.go @@ -168,13 +168,14 @@ func (c *PrintMsg) Execute(exCtx ExecutionContext) (Executer, error) { fmt.Fprintf(exCtx.Output(), "%s\n", output) - if !reflect.ValueOf(exCtx.OutputFile()).IsNil() { + outputFile := exCtx.OutputFile() + if outputFile != nil && !reflect.ValueOf(outputFile).IsNil() { output, err := exCtx.Formater().FormatForFile(msg) if err != nil { return nil, err } - _, err = fmt.Fprintln(exCtx.OutputFile(), output) + _, err = fmt.Fprintln(outputFile, output) if err != nil { return nil, err }