Proposal: `File.basename` and `File.dirname`
joshgoebel opened this issue · comments
This has recently come up in wren-console
: joshgoebel#16
Talking about adding:
File.dirname(path)
- Strip last component from file nameFile.basename(path)
- Strip directory from filenamesFile.basename(path, suffixes)
- Strip directory and suffix from filenames
The existing test infrastructure is a bit frustrating to use for testing like this vs a traditional testing framework. I wanted to open this here to see if there is interest in getting this functionality (basename/dirname) into the official CLI. If not, then we may switch to a much simpler testing framework for these tests. On the other hand, if we wish to upstream this change, then it makes sense to stick with the existing testing infrastructure.
One question if this was to land in CLI proper where should we place "core-like" utility functions, such as stringLastIndexOf
... it doesn't seem correct to just leave this laying around in the File
class as it may need to be reused more broadly in the future... do we need a util
or tools
module?