Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only warn if a glob does not match any files, but error if total is 0 #328

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion generate/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func getSchema(globs StringList) (*ast.Schema, error) {
return nil, err
}

if len(filenames) == 0 {
return nil, errorf(nil, "no schema files found in: %v", globs)
}

sources := make([]*ast.Source, len(filenames))
for i, filename := range filenames {
text, err := os.ReadFile(filename)
Expand Down Expand Up @@ -92,7 +96,7 @@ func expandFilenames(globs []string) ([]string, error) {
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)
warn(errorf(nil, "%v did not match any files", glob))
}
for _, match := range matches {
uniqFilenames[match] = true
Expand Down Expand Up @@ -123,6 +127,10 @@ func getQueries(basedir string, globs StringList) (*ast.QueryDocument, error) {
return nil, err
}

if len(filenames) == 0 {
return nil, errorf(nil, "no query files found in: %v", globs)
}

stormsweeper marked this conversation as resolved.
Show resolved Hide resolved
for _, filename := range filenames {
text, err := os.ReadFile(filename)
if err != nil {
Expand Down
Loading