If this is over-engineered, then I'm not particularly attached to it, but let's see what we think.
We have a lot of Path.mkdir sprinkled throughout the code, which makes sense, as we create a lot of exports in a nested file hierarchy. However, I've been bit a couple times now by forgetting or misconfiguring a mkdir, and I'd like to help us avoid future bugs.
What I've done is wrapped around the Path class to give us ValidPath, which essentially guarantees the existence of whichever directory you're trying to write to. (This is especially helpful when nesting downwards, since class(ValidPath(".") / "child") == ValidPath.)
If this is over-engineered, then I'm not particularly attached to it, but let's see what we think.
We have a lot of
Path.mkdir
sprinkled throughout the code, which makes sense, as we create a lot of exports in a nested file hierarchy. However, I've been bit a couple times now by forgetting or misconfiguring amkdir
, and I'd like to help us avoid future bugs.What I've done is wrapped around the
Path
class to give usValidPath
, which essentially guarantees the existence of whichever directory you're trying to write to. (This is especially helpful when nesting downwards, sinceclass(ValidPath(".") / "child") == ValidPath
.)For example, from our codebase,
becomes
and
becomes