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
|
package sort
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"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
|
// AlphaNumeric sorts the JSON output so that tasks are in alpha numeric order
|
||||||
// by task name.
|
// by task name.
|
||||||
func AlphaNumeric(items []string, namespaces []string) []string {
|
func AlphaNumeric(items []string, namespaces []string) []string {
|
||||||
sort.Slice(items, func(i, j int) bool {
|
slices.Sort(items)
|
||||||
return items[i] < items[j]
|
|
||||||
})
|
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package templater
|
package templater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"maps"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -60,13 +61,9 @@ func init() {
|
|||||||
cap += len(m)
|
cap += len(m)
|
||||||
}
|
}
|
||||||
result := make(map[string]any, cap)
|
result := make(map[string]any, cap)
|
||||||
for k, v := range base {
|
maps.Copy(result, base)
|
||||||
result[k] = v
|
|
||||||
}
|
|
||||||
for _, m := range v {
|
for _, m := range v {
|
||||||
for k, v := range m {
|
maps.Copy(result, m)
|
||||||
result[k] = v
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
@ -84,7 +81,5 @@ func init() {
|
|||||||
taskFuncs["ExeExt"] = taskFuncs["exeExt"]
|
taskFuncs["ExeExt"] = taskFuncs["exeExt"]
|
||||||
|
|
||||||
templateFuncs = template.FuncMap(sprig.TxtFuncMap())
|
templateFuncs = template.FuncMap(sprig.TxtFuncMap())
|
||||||
for k, v := range taskFuncs {
|
maps.Copy(templateFuncs, taskFuncs)
|
||||||
templateFuncs[k] = v
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package task
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -378,9 +379,7 @@ func product(matrix *ast.Matrix) []map[string]any {
|
|||||||
for _, item := range row.Value {
|
for _, item := range row.Value {
|
||||||
newComb := make(map[string]any, len(combination))
|
newComb := make(map[string]any, len(combination))
|
||||||
// Copy the existing combination
|
// Copy the existing combination
|
||||||
for k, v := range combination {
|
maps.Copy(newComb, combination)
|
||||||
newComb[k] = v
|
|
||||||
}
|
|
||||||
// Add the current item with the corresponding key
|
// Add the current item with the corresponding key
|
||||||
newComb[key] = item
|
newComb[key] = item
|
||||||
newResult = append(newResult, newComb)
|
newResult = append(newResult, newComb)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user