Skip to content

Commit fd4fb04

Browse files
committed
fix: 修复windows平台通配符匹配问题
1 parent c98b441 commit fd4fb04

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

commands.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,12 @@ func NewUploadCommand() cli.Command {
370370
if c.Int("w") > 10 || c.Int("w") < 1 {
371371
PrintErrorAndExit("max concurrent threads must between (1 - 10)")
372372
}
373+
filenames := c.Args()
374+
if isWindowsGOOS() {
375+
filenames = globFiles(filenames)
376+
}
373377
session.Upload(
374-
c.Args(),
378+
filenames,
375379
c.String("remote"),
376380
c.Int("w"),
377381
c.Bool("all"),

utils.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"fmt"
66
"io"
77
"os"
8+
"path/filepath"
9+
"runtime"
810
"strconv"
911
"strings"
1012
"time"
@@ -140,3 +142,20 @@ func contains(slice []string, item string) bool {
140142
}
141143
return false
142144
}
145+
146+
func globFiles(patterns []string) []string {
147+
filenames := make([]string, 0)
148+
for _, filename := range patterns {
149+
if strings.Contains(filename, "*") {
150+
matches, err := filepath.Glob(filename)
151+
if err == nil {
152+
filenames = append(filenames, matches...)
153+
}
154+
}
155+
}
156+
return filenames
157+
}
158+
159+
func isWindowsGOOS() bool {
160+
return runtime.GOOS == "windows"
161+
}

0 commit comments

Comments
 (0)