mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-02 07:04:48 +08:00
When split expression includes an extension, dont add .yml automatically
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
@@ -67,7 +68,10 @@ func (sp *multiPrintWriter) GetWriter(node *CandidateNode) (*bufio.Writer, error
|
||||
if result.MatchingNodes.Len() > 0 {
|
||||
name = result.MatchingNodes.Front().Value.(*CandidateNode).Node.Value
|
||||
}
|
||||
name = fmt.Sprintf("%v.%v", name, sp.extension)
|
||||
var extensionRegexp = regexp.MustCompile(`\.[a-zA-Z0-9]+$`)
|
||||
if !extensionRegexp.MatchString(name) {
|
||||
name = fmt.Sprintf("%v.%v", name, sp.extension)
|
||||
}
|
||||
|
||||
f, err := os.Create(name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user