Resolve output file paths to absolute paths to ensure files are created in the expected location
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ae23eaad69
commit
e4c218d67c
1 changed files with 10 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -32,6 +33,15 @@ func Exec(ctx context.Context, args Args) error {
|
|||
}
|
||||
|
||||
for _, o := range args.Output {
|
||||
// If the output spec contains a file path (FORMAT=FILE), resolve it to an absolute path.
|
||||
if idx := strings.Index(o, "="); idx >= 0 {
|
||||
filePath := o[idx+1:]
|
||||
if !filepath.IsAbs(filePath) {
|
||||
if wd, err := os.Getwd(); err == nil {
|
||||
o = o[:idx+1] + filepath.Join(wd, filePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
cmdArgs = append(cmdArgs, "--output", o)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue