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 ```
This commit is contained in:
@@ -72,6 +72,9 @@ func expandFilenames(globs []string) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, errorf(nil, "can't expand file-glob %v: %v", glob, err)
|
||||
}
|
||||
if len(matches) == 0 {
|
||||
return nil, errorf(nil, "%v did not match any files", glob)
|
||||
}
|
||||
for _, match := range matches {
|
||||
uniqFilenames[match] = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user