Skip to content

Commit

Permalink
Release v4.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
j3ssie committed Dec 5, 2023
1 parent 0feb6b8 commit eaadf9a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions core/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,21 @@ 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
}
return otto.Value{}
})

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
}
Expand Down Expand Up @@ -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
})
Expand Down
20 changes: 12 additions & 8 deletions core/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 != "" {
Expand Down
12 changes: 10 additions & 2 deletions execution/beautify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit eaadf9a

Please sign in to comment.