Refactor test to prevent panic

Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
Jhon Honce
2019-10-31 14:15:55 -07:00
parent e7540d0406
commit 3bf594e262

View File

@@ -68,7 +68,8 @@ func aliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
// Check if a file exists and is not a directory
func checkIfFileExists(name string) bool {
file, err := os.Stat(name)
if os.IsNotExist(err) {
// All errors return file == nil
if err != nil {
return false
}
return !file.IsDir()