This is an automated email from the ASF dual-hosted git repository.
linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git
The following commit(s) were added to refs/heads/dev by this push:
new 71d11b62 fix: resolve local plugin paths to absolute and enhance
module replacement logic
71d11b62 is described below
commit 71d11b6205de522624d3154f080a04e9436732d3
Author: hgaol <[email protected]>
AuthorDate: Mon Apr 13 00:00:33 2026 +0800
fix: resolve local plugin paths to absolute and enhance module replacement
logic
---
internal/cli/build.go | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/internal/cli/build.go b/internal/cli/build.go
index efc876e3..68820fe0 100644
--- a/internal/cli/build.go
+++ b/internal/cli/build.go
@@ -140,6 +140,12 @@ func formatPlugins(plugins []string) (formatted
[]*pluginInfo) {
info := &pluginInfo{}
plugin, info.Path, _ = strings.Cut(plugin, "=")
info.Name, info.Version, _ = strings.Cut(plugin, "@")
+ // Resolve local path to absolute since build runs in a temp
directory
+ if len(info.Path) > 0 {
+ if absPath, err := filepath.Abs(info.Path); err == nil {
+ info.Path = absPath
+ }
+ }
formatted = append(formatted, info)
}
return formatted
@@ -185,7 +191,12 @@ func createMainGoFile(b *buildingMaterial) (err error) {
for _, p := range b.plugins {
// If user set a path, use it to replace the module with local
path
if len(p.Path) > 0 {
- replacement := fmt.Sprintf("%s@%s=%s", p.Name,
p.Version, p.Path)
+ var replacement string
+ if len(p.Version) > 0 {
+ replacement = fmt.Sprintf("%s@%s=%s", p.Name,
p.Version, p.Path)
+ } else {
+ replacement = fmt.Sprintf("%s=%s", p.Name,
p.Path)
+ }
err = b.newExecCmd("go", "mod", "edit", "-replace",
replacement).Run()
} else if len(p.Version) > 0 {
// If user specify a version, use it to get specific
version of the module
@@ -415,6 +426,13 @@ func copyDirEntries(sourceFs fs.FS, sourceDir, targetDir
string, ignoreDir ...st
if strings.HasPrefix(path, s) {
return true
}
+ // Also ignore nested occurrences, e.g.
src/plugins/foo/node_modules
+ if strings.Contains(path, string(filepath.Separator)+s)
{
+ return true
+ }
+ if strings.Contains(path, "/"+s) {
+ return true
+ }
}
return false
}