You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've run into this confusion a few times before. The behavior feels more obvious when you chain multiple WithNewFile calls because there's no nesting in that case, but WithNewDirectory can easily mislead you into thinking it returns the child.
I wonder if it should be called WithEmptyDirectory or something instead? (meh)
Activity
vito commentedon Nov 22, 2022
Don't think this is a bug, just another case of confusion between chaining additive changes to the parent vs. the child.
The problem is here:
This creates a directory, creates
/a/underneath it and returns the parent directory, and then creates another file beneath that parent directory.To create a file in a sub-directory, by far the easiest method is to fully specify the path:
If not for this shorthand I think you would have to create it inside-out like this:
We've run into this confusion a few times before. The behavior feels more obvious when you chain multiple
WithNewFilecalls because there's no nesting in that case, butWithNewDirectorycan easily mislead you into thinking it returns the child.I wonder if it should be called
WithEmptyDirectoryor something instead? (meh)