From e6dfebdbfe7b70fa4dee804732f7c875600c9575 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Tue, 20 Oct 2020 11:15:46 -0600 Subject: [PATCH] Warn if mkpuzzle is not executable --- pkg/transpile/puzzle.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pkg/transpile/puzzle.go b/pkg/transpile/puzzle.go index 77a9ed1..4d9c512 100644 --- a/pkg/transpile/puzzle.go +++ b/pkg/transpile/puzzle.go @@ -11,6 +11,7 @@ import ( "io" "log" "net/mail" + "os" "os/exec" "path" "strconv" @@ -140,16 +141,20 @@ type PuzzleProvider interface { func NewFsPuzzle(fs afero.Fs) PuzzleProvider { var command string - if info, err := fs.Stat("mkpuzzle"); (err == nil) && (info.Mode()&0100 != 0) { - // Try to get the actual path to the executable - if pfs, ok := fs.(*RecursiveBasePathFs); ok { - if command, err = pfs.RealPath(info.Name()); err != nil { - log.Println("Unable to resolve full path to", info.Name(), pfs) - } - } else if pfs, ok := fs.(*afero.BasePathFs); ok { - if command, err = pfs.RealPath(info.Name()); err != nil { - log.Println("Unable to resolve full path to", info.Name(), pfs) + if info, err := fs.Stat("mkpuzzle"); !os.IsNotExist(err) { + if (info.Mode() & 0100) != 0 { + // Try to get the actual path to the executable + if pfs, ok := fs.(*RecursiveBasePathFs); ok { + if command, err = pfs.RealPath(info.Name()); err != nil { + log.Println("WARN: Unable to resolve full path to", info.Name(), pfs) + } + } else if pfs, ok := fs.(*afero.BasePathFs); ok { + if command, err = pfs.RealPath(info.Name()); err != nil { + log.Println("WARN: Unable to resolve full path to", info.Name(), pfs) + } } + } else { + log.Println("WARN: mkpuzzle exists, but isn't executable.") } }