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
The docs seem to indicate that fs.move(dir, otherDir, { clobber: true }) will move a directory even if there is already content there. Looking at the code it seems that the intent is for that to work for files, it probably works for empty directories (that rename() is happy with) but it doesn't work for directories that have content. For that you need to fs.remove() them first. Maybe that's intentional (the tests don't exercise this case) but if so it should be documented as such.
The text was updated successfully, but these errors were encountered:
Hmm. Good point. Do you think it makes sense to "move" a directory to a new directory that has content? It seems to me that should almost always produce an error. But since the functionality is provided for files, perhaps it should be possible for directories since the {clobber: true} makes the intent explicit.
There are cases when you just want to overwrite the directory. In my situation, I have cases in which I can just regenerate a subset of the content, and others in which being smart is hopeless and I just generate a fresh copy to replace the old with. In the latter case I need to build the fresh copy in a temp dir and replace the live one. I'd say if you've specified clobber, you should get clobber :)
The docs seem to indicate that
fs.move(dir, otherDir, { clobber: true })
will move a directory even if there is already content there. Looking at the code it seems that the intent is for that to work for files, it probably works for empty directories (thatrename()
is happy with) but it doesn't work for directories that have content. For that you need tofs.remove()
them first. Maybe that's intentional (the tests don't exercise this case) but if so it should be documented as such.The text was updated successfully, but these errors were encountered: