fix: Create errors-file if it does not exist (#520)
When passed `--errors-file`, the file should not need to already exist on disk to be written into
This commit is contained in:
parent
3a37835386
commit
9db72b0445
@ -56,6 +56,16 @@ func (p *writeParams) makeErrorFile() (*os.File, error) {
|
||||
if p.ErrorsFile == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
_, err := os.Stat(p.ErrorsFile)
|
||||
if os.IsNotExist(err) {
|
||||
file, err := os.Create(p.ErrorsFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create errors-file: %w", err)
|
||||
}
|
||||
return file, nil
|
||||
}
|
||||
|
||||
errorFile, err := os.Open(p.ErrorsFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to open errors-file: %w", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user