test case fixing

packer_fmt_multi_args
anshul sharma 1 year ago
parent bfb3264587
commit 7c10b2d7ac

@ -36,10 +36,10 @@ func (c *FormatCommand) ParseArgs(args []string) (*FormatArgs, int) {
}
args = flags.Args()
/*if len(args) != 1 {
if len(args) == 0 {
flags.Usage()
return &cfg, 1
}*/
}
//cfg.Path = args[0]
cfg.Paths = args

@ -121,7 +121,7 @@ func (f *HCL2Formatter) FormatNew(paths []string) (int, hcl.Diagnostics) {
for _, path := range paths {
s, err := os.Stat(path)
if err != nil {
/*if err != nil {
diag := &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: fmt.Sprintf("No file or directory at %s", path),
@ -129,24 +129,24 @@ func (f *HCL2Formatter) FormatNew(paths []string) (int, hcl.Diagnostics) {
}
diags = append(diags, diag)
return 0, diags
}
}*/
if !s.IsDir() {
fmtd := false
if err != nil || !s.IsDir() {
bytesModified, diags = f.formatFile(path, diags, bytesModified)
/*formatted := false
if isHcl2FileOrVarFile(path) {
bytesModified, diags = f.formatFile(path, diags, bytesModified)
fmtd = true
formatted = true
}
if !fmtd {
if !formatted {
diag := &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Only .pkr.hcl and .pkrvars.hcl files can be processed with packer fmt",
}
diags = append(diags, diag)
continue
}
}*/
} else {
fileInfos, err := os.ReadDir(path)
if err != nil {

Loading…
Cancel
Save