From 160d932ccef5aafd74cc25d342a941f8c1ff8178 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 15 Mar 2021 12:04:16 +0100 Subject: [PATCH] remove weir "Cannot tell wether " + path + " is a directory" error --- hcl2template/formatter.go | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/hcl2template/formatter.go b/hcl2template/formatter.go index d59a9eb8f..34d63e8de 100644 --- a/hcl2template/formatter.go +++ b/hcl2template/formatter.go @@ -69,21 +69,7 @@ func (f *HCL2Formatter) Format(path string) (int, hcl.Diagnostics) { f.parser = hclparse.NewParser() } - if path == "-" { - return f.formatFile(path, diags, bytesModified) - } - - isDir, err := isDir(path) - if err != nil { - diags = append(diags, &hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: "Cannot tell wether " + path + " is a directory", - Detail: err.Error(), - }) - return bytesModified, diags - } - - if !isDir { + if s, err := os.Stat(path); err != nil || !s.IsDir() { return f.formatFile(path, diags, bytesModified) }