diff --git a/core/module.go b/core/module.go index 0374f51..5237b76 100644 --- a/core/module.go +++ b/core/module.go @@ -170,7 +170,7 @@ func (r *Runner) RunStepWithTimeout(timeout int, step libs.Step) (out string, er func (r *Runner) RunStep(step libs.Step) (string, error) { var output string if step.Label != "" { - utils.TSPrintF("Initiating Step %v", color.HiGreenString(step.Label)) + utils.TSPrintF("Initiating step %v", color.HiGreenString(step.Label)) } // checking required file diff --git a/core/runtime.go b/core/runtime.go index e8c7bd7..58dbf68 100644 --- a/core/runtime.go +++ b/core/runtime.go @@ -189,9 +189,10 @@ func (r *Runner) LoadScripts() string { }) vm.Set(FileLength, func(call otto.FunctionCall) otto.Value { - data := utils.FileLength(call.Argument(0).String()) - utils.DebugF("FileLength -- %v", data) - result, err := vm.ToValue(data) + filename := call.Argument(0).String() + length := utils.FileLength(filename) + utils.DebugF("FileLength(%v) -- %v", filename, length) + result, err := vm.ToValue(length) if err == nil { return result } @@ -199,9 +200,10 @@ func (r *Runner) LoadScripts() string { }) vm.Set(FolderLength, func(call otto.FunctionCall) otto.Value { - data := utils.FolderLength(call.Argument(0).String()) - utils.DebugF("FolderLength -- %v", data) - result, err := vm.ToValue(data) + folderName := call.Argument(0).String() + length := utils.FileLength(folderName) + utils.DebugF("FolderLength(%v) -- %v", folderName, length) + result, err := vm.ToValue(length) if err == nil { return result } @@ -243,14 +245,14 @@ func (r *Runner) LoadScripts() string { // Printf simply print a string to console vm.Set(Printf, func(call otto.FunctionCall) otto.Value { - utils.InforF(" %v", color.HiWhiteString(call.Argument(0).String())) + utils.InforF("%v", color.HiWhiteString(call.Argument(0).String())) returnValue, _ := otto.ToValue(true) return returnValue }) // Warnf simply print a string to console vm.Set(Warnf, func(call otto.FunctionCall) otto.Value { - utils.InforF(" %v", color.HiRedString(call.Argument(0).String())) + utils.InforF("%v", color.HiRedString(call.Argument(0).String())) returnValue, _ := otto.ToValue(true) return returnValue }) diff --git a/core/step.go b/core/step.go index 78bafde..1de9469 100644 --- a/core/step.go +++ b/core/step.go @@ -78,19 +78,23 @@ func printReports(module libs.Module) { files = append(files, module.Report.Diff...) reports := funk.UniqString(files) - if len(reports) == 0 { - utils.DebugF("No report generated by the %v module", module.Name) - return - } - - utils.PrefixF(" ", strings.Repeat("-", 40)) - utils.PrefixF("📄 ", "List of %v reports generated by the %v module", color.HiMagentaString("%v", len(reports)), color.HiGreenString(module.Name)) + var validReports []string for _, report := range reports { if !utils.FileExists(report) && utils.EmptyFile(report, 0) { if !utils.FolderExists(report) && utils.EmptyDir(report) { continue } } + validReports = append(validReports, report) + } + + if len(validReports) == 0 { + utils.DebugF("No report generated by the %v module", module.Name) + return + } + utils.PrefixF(" ", strings.Repeat("-", 40)) + utils.PrefixF("📄 ", "List of %v reports generated by the %v module", color.HiMagentaString("%v", len(validReports)), color.HiGreenString(module.Name)) + for _, report := range validReports { utils.PrefixF(" ", "|-- %v", color.HiCyanString(report)) } utils.PrefixF(" ", strings.Repeat("-", 40)) @@ -160,7 +164,7 @@ func (r *Runner) RunCommands(commands []string, std string) string { } if err != nil { - utils.DebugF("error running command: %v -- %v", command, err) + utils.DebugF("error running command: %v -- %v", color.HiYellowString(command), err) } if out != "" { diff --git a/execution/beautify.go b/execution/beautify.go index d28b593..173cf3d 100644 --- a/execution/beautify.go +++ b/execution/beautify.go @@ -18,7 +18,11 @@ func PrintCSV(filename string) { // Create a new table table := tablewriter.NewWriter(os.Stdout) - for _, record := range records { + for index, record := range records { + if index == 0 { + table.SetHeader(record) + continue + } table.Append(record) } table.SetRowLine(false) @@ -38,7 +42,11 @@ func BeautifyCSV(filename string, dest string) { // Create a new table var buf bytes.Buffer table := tablewriter.NewWriter(&buf) - for _, record := range records { + for index, record := range records { + if index == 0 { + table.SetHeader(record) + continue + } table.Append(record) } table.SetRowLine(false)