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.
This commit is contained in:
parent
653369eec5
commit
21640c5ec8
2 changed files with 10 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue