Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: panic when using --list and --silent #1512

Merged
merged 2 commits into from Feb 22, 2024
Merged

fix: panic when using --list and --silent #1512

merged 2 commits into from Feb 22, 2024

Conversation

pd93
Copy link
Member

@pd93 pd93 commented Feb 19, 2024

Fixes #1509

  • fix: setup logger if nil when listing task names
  • refactor: bubble errors from ListTaskNames

@andreynering An alternative approach to fixing this would be the following diff. It would simplify the code as we no longer have to conditionally load the taskfile/logger in ListTaskNames(). This obviously comes with a slight performance cost.

diff --git a/cmd/task/task.go b/cmd/task/task.go
index f3144703..17f9884c 100644
--- a/cmd/task/task.go
+++ b/cmd/task/task.go
@@ -264,15 +264,15 @@ func run() error {
                return err
        }
 
+       if err := e.Setup(); err != nil {
+               return err
+       }
+
        if (listOptions.ShouldListTasks()) && flags.silent {
                e.ListTaskNames(flags.listAll)
                return nil
        }
 
-       if err := e.Setup(); err != nil {
-               return err
-       }
-
        // If the download flag is specified, we should stop execution as soon as
        // taskfile is downloaded
        if flags.download {

@andreynering andreynering added type: bug Something not working as intended. area: remote Changes related to remote taskfiles. labels Feb 22, 2024
@andreynering andreynering merged commit 07a0b89 into main Feb 22, 2024
13 checks passed
@andreynering andreynering deleted the 1509-fix-panic branch February 22, 2024 00:06
andreynering added a commit that referenced this pull request Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: remote Changes related to remote taskfiles. type: bug Something not working as intended.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

task --slient --list-all with remote taskfiles causes panic
2 participants