mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
feat: Create parent directories if --split-exp is used.
Problem: When --split-exp is used and produces filenames with slashes in them, the target directories must already exist otherwise yq fails. Fix/feature: Create the necessary directories with os.MkdirAll(). The permissions 0750 were chosen to satisfy the vulnerability checker.
This commit is contained in:
committed by
Mike Farah
parent
294a1709ad
commit
f73c862cc5
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
@@ -70,6 +71,10 @@ func (sp *multiPrintWriter) GetWriter(node *CandidateNode) (*bufio.Writer, error
|
||||
name = fmt.Sprintf("%v.%v", name, sp.extension)
|
||||
}
|
||||
|
||||
err = os.MkdirAll(filepath.Dir(name), 0750)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f, err := os.Create(name)
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user