mirror of
https://github.com/go-task/task.git
synced 2025-06-04 23:38:05 +02:00
refactor: run task through modernize tool (#2088)
This commit is contained in:
parent
b14125bacd
commit
fb631902ce
@ -1,6 +1,7 @@
|
||||
package sort
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
@ -11,9 +12,7 @@ type Sorter func(items []string, namespaces []string) []string
|
||||
// AlphaNumeric sorts the JSON output so that tasks are in alpha numeric order
|
||||
// by task name.
|
||||
func AlphaNumeric(items []string, namespaces []string) []string {
|
||||
sort.Slice(items, func(i, j int) bool {
|
||||
return items[i] < items[j]
|
||||
})
|
||||
slices.Sort(items)
|
||||
return items
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package templater
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
@ -60,13 +61,9 @@ func init() {
|
||||
cap += len(m)
|
||||
}
|
||||
result := make(map[string]any, cap)
|
||||
for k, v := range base {
|
||||
result[k] = v
|
||||
}
|
||||
maps.Copy(result, base)
|
||||
for _, m := range v {
|
||||
for k, v := range m {
|
||||
result[k] = v
|
||||
}
|
||||
maps.Copy(result, m)
|
||||
}
|
||||
return result
|
||||
},
|
||||
@ -84,7 +81,5 @@ func init() {
|
||||
taskFuncs["ExeExt"] = taskFuncs["exeExt"]
|
||||
|
||||
templateFuncs = template.FuncMap(sprig.TxtFuncMap())
|
||||
for k, v := range taskFuncs {
|
||||
templateFuncs[k] = v
|
||||
}
|
||||
maps.Copy(templateFuncs, taskFuncs)
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package task
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -378,9 +379,7 @@ func product(matrix *ast.Matrix) []map[string]any {
|
||||
for _, item := range row.Value {
|
||||
newComb := make(map[string]any, len(combination))
|
||||
// Copy the existing combination
|
||||
for k, v := range combination {
|
||||
newComb[k] = v
|
||||
}
|
||||
maps.Copy(newComb, combination)
|
||||
// Add the current item with the corresponding key
|
||||
newComb[key] = item
|
||||
newResult = append(newResult, newComb)
|
||||
|
Loading…
x
Reference in New Issue
Block a user