diff --git a/out_command.go b/out_command.go index e9f4038..14352eb 100644 --- a/out_command.go +++ b/out_command.go @@ -94,6 +94,10 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err return OutResponse{}, err } + if len(matches) == 0 { + return OutResponse{}, fmt.Errorf("could not find file that matches glob '%s'", fileGlob) + } + for _, filePath := range matches { file, err := os.Open(filePath) if err != nil { diff --git a/out_command_test.go b/out_command_test.go index 76e075a..f5d026d 100644 --- a/out_command_test.go +++ b/out_command_test.go @@ -204,6 +204,17 @@ var _ = Describe("Out Command", func() { resource.MetadataPair{Name: "body", Value: "*markdown*", Markdown: true}, )) }) + + It("returns an error if a glob is provided that does not match any files", func() { + request.Params.Globs = []string{ + "*.tgz", + "*.gif", + } + + _, err := command.Run(sourcesDir, request) + Ω(err).Should(HaveOccurred()) + Ω(err).Should(MatchError("could not find file that matches glob '*.gif'")) + }) }) }) })