Skip to content

Commit 49a26af

Browse files
Reject a glob that matches no files (#173)
The most important case here is if your glob isn't even a glob, it's just a filename. But even if it was a glob, it's probably a mistake; you'll probably end up with a confusing error due to an empty schema, or a slightly less confusing error due to not having any operations. Instead, let's just say outright that your glob didn't match any files. Fixes #146. Test plan: This was a bit annoying to test via snapshot, so I just tested it manually by modifying the example to use a glob that didn't match any files, first for the schema then for the operations, and got errors like ``` bogus*.graphql did not match any files exit status 1 example/main.go:68: running "go": exit status 1 ```
1 parent 67f2575 commit 49a26af

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

generate/parse.go

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ func expandFilenames(globs []string) ([]string, error) {
7272
if err != nil {
7373
return nil, errorf(nil, "can't expand file-glob %v: %v", glob, err)
7474
}
75+
if len(matches) == 0 {
76+
return nil, errorf(nil, "%v did not match any files", glob)
77+
}
7578
for _, match := range matches {
7679
uniqFilenames[match] = true
7780
}

0 commit comments

Comments
 (0)