From 38ea77ff5aa3a48caa567746474ae17694f02d48 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Mon, 9 Dec 2024 17:14:25 +0800 Subject: [PATCH] fix: solve prefix path filter. (#7) --- mageutil/basic.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mageutil/basic.go b/mageutil/basic.go index 5e06d36..3dc619b 100644 --- a/mageutil/basic.go +++ b/mageutil/basic.go @@ -90,11 +90,14 @@ func StartToolsAndServices() { func CompileForPlatform(platform string, compileBinaries []string) { var cmdBinaries, toolsBinaries []string + toolsPrefix := filepath.Join("tools", "") + cmdPrefix := filepath.Join("cmd", "") + for _, binary := range compileBinaries { - if strings.HasPrefix(binary, "tools/") { - toolsBinaries = append(toolsBinaries, strings.TrimPrefix(binary, "tools/")) - } else if strings.HasPrefix(binary, "cmd/") { - cmdBinaries = append(cmdBinaries, strings.TrimPrefix(binary, "cmd/")) + if strings.HasPrefix(binary, toolsPrefix) { + toolsBinaries = append(toolsBinaries, strings.TrimPrefix(binary, toolsPrefix)) + } else if strings.HasPrefix(binary, cmdPrefix) { + cmdBinaries = append(cmdBinaries, strings.TrimPrefix(binary, cmdPrefix)) } else { PrintYellow(fmt.Sprintf("Binary %s does not have a valid prefix. Skipping...", binary)) }