diff --git a/configlet/fixtures/track/amethyst/.keep b/configlet/fixtures/track/exercises/amethyst/.keep similarity index 100% rename from configlet/fixtures/track/amethyst/.keep rename to configlet/fixtures/track/exercises/amethyst/.keep diff --git a/configlet/fixtures/track/amethyst/example.txt b/configlet/fixtures/track/exercises/amethyst/example.txt similarity index 100% rename from configlet/fixtures/track/amethyst/example.txt rename to configlet/fixtures/track/exercises/amethyst/example.txt diff --git a/configlet/track.go b/configlet/track.go index 913e537..b86f10a 100644 --- a/configlet/track.go +++ b/configlet/track.go @@ -93,30 +93,30 @@ func (t Track) Dirs() (map[string]struct{}, error) { } for _, info := range infos { - if info.IsDir() { + if info.IsDir() && info.Name() != "exercises" { dirs[info.Name()] = struct{}{} } } - return dirs, nil -} -// ExerciseDirs lists all directories within the "exercises" directory. -// An implemented problem must be either in the root (legacy) or in the -// exercises dir. -func (t Track) ExerciseDirs() (map[string]struct{}, error) { - dirs := make(map[string]struct{}) + path := filepath.Join(t.path, "exercises") + if _, err := os.Stat(path); err != nil { + if os.IsNotExist(err) { + return dirs, nil + } + return dirs, err + } - infos, err := ioutil.ReadDir(filepath.Join(t.path, "exercises")) + infos, err = ioutil.ReadDir(filepath.Join(t.path, "exercises")) if err != nil { - fmt.Println(err) return dirs, err } for _, info := range infos { - if info.IsDir() { + if info.IsDir() && info.Name() != "exercises" { dirs[info.Name()] = struct{}{} } } + return dirs, nil }