From 5201051bc185c60547d4c72623b7a481b36e970c Mon Sep 17 00:00:00 2001 From: novalagung Date: Thu, 25 May 2023 02:27:43 +0700 Subject: [PATCH] fix: panic error on empty args when using depot cache reset command --- pkg/cmd/cache/reset.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/cache/reset.go b/pkg/cmd/cache/reset.go index a3f99a7a..795f8534 100644 --- a/pkg/cmd/cache/reset.go +++ b/pkg/cmd/cache/reset.go @@ -25,11 +25,11 @@ func NewCmdResetCache() *cobra.Command { Short: "Reset the cache for a project", Args: cli.RequiresMaxArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - cwd, _ := filepath.Abs(args[0]) - projectID := helpers.ResolveProjectID(projectID, cwd) - if projectID == "" { - return errors.Errorf("unknown project ID (run `depot init` or use --project or $DEPOT_PROJECT_ID)") + var cwd string + if len(args) > 0 { + cwd, _ = filepath.Abs(args[0]) } + projectID := helpers.ResolveProjectID(projectID, cwd) if projectID == "" { return errors.Errorf("unknown project ID (run `depot init` or use --project or $DEPOT_PROJECT_ID)") }