Handle empty files

This commit is contained in:
Mike Farah
2021-07-16 21:08:20 +10:00
parent a13617407e
commit 28a8721f49
4 changed files with 51 additions and 12 deletions
+11
View File
@@ -68,6 +68,17 @@ func (e *allAtOnceEvaluator) EvaluateFiles(expression string, filenames []string
allDocuments.PushBackList(fileDocuments)
fileIndex = fileIndex + 1
}
if allDocuments.Len() == 0 {
candidateNode := &CandidateNode{
Document: 0,
Filename: "",
Node: &yaml.Node{Tag: "!!null", Kind: yaml.ScalarNode},
FileIndex: 0,
}
allDocuments.PushBack(candidateNode)
}
matches, err := e.EvaluateCandidateNodes(expression, allDocuments)
if err != nil {
return err