From 22d373c2794f491b97b7982a1d1b54c519cab6f3 Mon Sep 17 00:00:00 2001 From: teddylear Date: Sun, 14 Mar 2021 19:42:53 -0400 Subject: [PATCH] Adding more debug logic --- command/fmt_test.go | 6 +++--- hcl2template/formatter.go | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/command/fmt_test.go b/command/fmt_test.go index 66eca802d..fe539490b 100644 --- a/command/fmt_test.go +++ b/command/fmt_test.go @@ -159,13 +159,13 @@ func Test_fmt_pipe(t *testing.T) { p := helperCommand(t, tc.command...) p.Stdin = strings.NewReader(tc.piped) p.Env = append(p.Env, tc.env...) + fmt.Println(fmt.Sprintf("Path: %s", p.Path)) bs, err := p.Output() if err != nil { - t.Fatalf("%v: %s", err, bs) + t.Fatalf("Error occurred running command %v: %s", err, bs) } - if diff := cmp.Diff(tc.expected, string(bs)); diff != "" { - t.Fatalf("%s", diff) + t.Fatalf("Error in diff: %s", diff) } }) } diff --git a/hcl2template/formatter.go b/hcl2template/formatter.go index 42534805d..286d1b1e5 100644 --- a/hcl2template/formatter.go +++ b/hcl2template/formatter.go @@ -69,6 +69,15 @@ func (f *HCL2Formatter) Format(path string) (int, hcl.Diagnostics) { f.parser = hclparse.NewParser() } + fmt.Println(fmt.Sprintf("Path is %s", path)) + if path == "-" { + fmt.Println("Found right statement!!!!!") + bytesModified, diags = f.formatFile(path, diags, bytesModified) + return bytesModified, diags + } else { + fmt.Println("Did not hit the correct statement") + } + isDir, err := isDir(path) if err != nil { diags = append(diags, &hcl.Diagnostic{