dirExists checks if the path exists and is a directory.
(name string)
| 342 | |
| 343 | // dirExists checks if the path exists and is a directory. |
| 344 | func dirExists(name string) (bool, error) { |
| 345 | fi, err := os.Stat(name) |
| 346 | if err != nil { |
| 347 | if os.IsNotExist(err) { |
| 348 | return false, nil |
| 349 | } |
| 350 | |
| 351 | return false, xerrors.Errorf("stat dir: %w", err) |
| 352 | } |
| 353 | if !fi.IsDir() { |
| 354 | return false, xerrors.New("exists but not a directory") |
| 355 | } |
| 356 | |
| 357 | return true, nil |
| 358 | } |
| 359 | |
| 360 | // findScript will find the first file that matches the script set. |
| 361 | func findScript(scriptSet []string, directory string) string { |