Release v4.6.3

This commit is contained in:
j3ssie
2023-12-05 20:50:18 +07:00
parent 0feb6b842e
commit eaadf9aaa4
4 changed files with 33 additions and 19 deletions
+1 -1
View File
@@ -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
+10 -8
View File
@@ -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
})
+12 -8
View File
@@ -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 != "" {
+10 -2
View File
@@ -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)