Skip to content

Commit

Permalink
Also return ErrUnknownFileType for directories
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Jul 3, 2018
1 parent 58f22cc commit 9e625b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion util/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ func ExampleRun() {

// Create a simple test script
filename := "test-script"
script := "#!/bin/bash\necho -n Happy Hour"
script := `#!/bin/bash
echo -n Happy Hour
`

// Make sure script is executable!
if err := ioutil.WriteFile(filename, []byte(script), 0700); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions util/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"bytes"
"encoding/json"
"errors"
"fmt"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -107,7 +106,7 @@ func (rs Runners) Run(filename string, args ...string) ([]byte, error) {
return nil, err
}
if fi.IsDir() {
return nil, fmt.Errorf("%s is a directory", filename)
return nil, ErrUnknownFileType
}

// See if a runner will accept file
Expand Down

0 comments on commit 9e625b3

Please sign in to comment.