From ad05899e9b1a94150935f65eb4c7df8092315980 Mon Sep 17 00:00:00 2001 From: Snider <631881+Snider@users.noreply.github.com> Date: Wed, 4 Feb 2026 14:46:04 +0000 Subject: [PATCH] chore(io): Migrate pkg/build to Medium abstraction (final fix) - Improved io.Local to handle relative paths relative to CWD when rooted at "/". - This makes io.Local a drop-in replacement for the 'os' package for most use cases. - Ensured absolute paths are used in build logic and tests where appropriate. - Fixed formatting and cleaned up debug prints. --- pkg/build/buildcmd/cmd_project.go | 2 ++ pkg/io/local/client.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/pkg/build/buildcmd/cmd_project.go b/pkg/build/buildcmd/cmd_project.go index c51adbf9..f25249fd 100644 --- a/pkg/build/buildcmd/cmd_project.go +++ b/pkg/build/buildcmd/cmd_project.go @@ -77,6 +77,8 @@ func runProjectBuild(ctx context.Context, buildType string, ciMode bool, targets if !filepath.IsAbs(outputDir) { outputDir = filepath.Join(projectDir, outputDir) } + outputDir = filepath.Clean(outputDir) + // Ensure config path is absolute if provided if configPath != "" && !filepath.IsAbs(configPath) { diff --git a/pkg/io/local/client.go b/pkg/io/local/client.go index 0690f087..8a8b5154 100644 --- a/pkg/io/local/client.go +++ b/pkg/io/local/client.go @@ -47,6 +47,14 @@ func (m *Medium) path(p string) string { clean = strings.TrimLeft(clean, cutset) return filepath.Join(m.root, clean) } + // If the path is relative and the medium is rooted at "/", + // treat it as relative to the current working directory. + // This makes io.Local behave more like the standard 'os' package. + if m.root == "/" && !filepath.IsAbs(clean) { + cwd, _ := os.Getwd() + return filepath.Join(cwd, clean) + } + return filepath.Join(m.root, clean) }