Skip to content

Commit 05e3d57

Browse files
committed
mod: avoid static vex path
Signed-off-by: Joshua Duffney <[email protected]>
1 parent 6a05ac0 commit 05e3d57

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

internal/copa/cli.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ func (c *CLI) BuildWithReport() *CLI {
135135

136136
if c.reportPath != "" {
137137
c.cmd.Args = append(c.cmd.Args, "--report", c.reportPath)
138-
c.vexPath = filepath.Join(os.TempDir(), defaultVexFile)
139-
c.cmd.Args = append(c.cmd.Args, "--output", c.vexPath)
140138
}
141139

142140
return c
@@ -157,6 +155,18 @@ func (c *CLI) setupAuth() error {
157155
return nil
158156
}
159157

158+
func (c *CLI) setupVexDir() error {
159+
if c.reportPath != "" {
160+
path, err := os.MkdirTemp(os.TempDir(), "vex-*")
161+
if err != nil {
162+
return err
163+
}
164+
c.vexPath = filepath.Join(path, defaultVexFile)
165+
c.cmd.Args = append(c.cmd.Args, "--output", c.vexPath)
166+
}
167+
return nil
168+
}
169+
160170
func (c *CLI) validateCommand() error {
161171
if c.cmd == nil {
162172
return fmt.Errorf("no command built - call a Build method first")
@@ -235,6 +245,10 @@ func (c *CLI) Run(ctx context.Context) (*ExecutionResult, error) {
235245
return nil, fmt.Errorf("authentication setup failed: %w", err)
236246
}
237247

248+
if err := c.setupVexDir(); err != nil {
249+
return nil, fmt.Errorf("creating vex temp dir failed: %w", err)
250+
}
251+
238252
result, err := c.execute(ctx)
239253
if err != nil {
240254
return result, fmt.Errorf("execution failed: %w", err)

0 commit comments

Comments
 (0)