ianmackenzie / ianmackenzie/elm-script

Helper functions for recursively getting files and subdirectories

Open
#24 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
34
Forks
5
PR merge metrics
No merged PRs in 30d

Description

I noticed that while there is `Script.Directory.listFiles` and `Script.Directory.listSubdirectories` they don't list any items in subdirectories.

I think it would be useful to have something like this too (and something similar for recursively listing all subdirectories):
```elm
listAllFiles : Script.Directory.Directory permissions -> Script String (List (Script.File.File permissions))
listAllFiles directory =
Script.map2 (++)
(Script.Directory.listFiles directory)
(Script.Directory.listSubdirs directory
|> Script.thenWith (List.map listAllFiles >> Script.sequence >> Script.map List.concat)
)
```
This implementation doesn't bother handling edge cases like "What happens if we fail to read a file/directory after it gets listed in a subdirectory?" and "What happens if there's a symbolic link that to directory higher up, trapping us in a loop?" I'm not sure what should be done in these cases.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.