Skip to content

Commit dde18bc

Browse files
committed
fix: Correct file path when copying to clipboard
- Use outputPath consistently for file operations - Ensure absolute path is passed to clipboard operations
1 parent 58bbee0 commit dde18bc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

internal/generator/generator.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ func (g *Generator) Generate() (string, int, int, error) {
125125
return displayPath, tokenCount, g.lastSecretCount, fmt.Errorf("failed to get absolute path: %w", err)
126126
}
127127

128-
if err := os.WriteFile(absPath, []byte(content), 0644); err != nil {
128+
if err := os.WriteFile(outputPath, []byte(content), 0644); err != nil {
129129
return displayPath, tokenCount, g.lastSecretCount, fmt.Errorf("failed to write to output file %s: %w", absPath, err)
130130
}
131+
132+
outputPath = absPath
131133
}
132134

133135
if err := utils.CopyFileObject(outputPath); err != nil {
134-
fmt.Fprintf(os.Stderr, "Warning: clipboard copy failed: %v\n", err)
136+
return displayPath, tokenCount, g.lastSecretCount, fmt.Errorf("clipboard copy failed: %w", err)
135137
}
136138

137139
return displayPath, tokenCount, g.lastSecretCount, nil

0 commit comments

Comments
 (0)