From 65506c1992b1d0746f4c7d35698813be535a6b74 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Sat, 12 Oct 2024 14:05:09 +0200 Subject: [PATCH] fix: also check if path is in project for --stdin --stdin should operate under the same rules as the other walkers. --- cmd/format/format.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/format/format.go b/cmd/format/format.go index 8bfae813..ce70947f 100644 --- a/cmd/format/format.go +++ b/cmd/format/format.go @@ -172,13 +172,13 @@ func Run(v *viper.Viper, statz *stats.Stats, cmd *cobra.Command, paths []string) if len(paths) != 1 { return fmt.Errorf("exactly one path should be specified when using the --stdin flag") } - } else { - // checks all paths are contained within the tree root - for _, path := range paths { - rootPath := filepath.Join(cfg.TreeRoot, path) - if _, err = os.Stat(rootPath); err != nil { - return fmt.Errorf("path %s not found within the tree root %s", path, cfg.TreeRoot) - } + } + + // checks all paths are contained within the tree root + for _, path := range paths { + rootPath := filepath.Join(cfg.TreeRoot, path) + if _, err = os.Stat(rootPath); err != nil { + return fmt.Errorf("path %s not found within the tree root %s", path, cfg.TreeRoot) } }