node-fs-extra icon indicating copy to clipboard operation
node-fs-extra copied to clipboard

--merge option for move

Open kellyselden opened this issue 5 years ago • 4 comments

I have the need for the following workflow:

  • if dest doesn't exist, move
  • otherwise, loop over contents
    • repeat

The main difference with the current move is that it deletes the dest before the move, whereas this would merge if conflicted. I figured I would offer to attempt to build it here instead of a new package, if you're interested.

kellyselden avatar Apr 05 '19 20:04 kellyselden

Not sure I understand what you mean by "loop over contents"

RyanZim avatar Apr 05 '19 21:04 RyanZim

If it's a folder, readdir and repeat the check for all contents, then recurse until done. The goal is short-circuit at every opportunity to just do a move/rename.

kellyselden avatar Apr 05 '19 22:04 kellyselden

Hmm, seems pretty complicated. Basically like rsync, but moving instead of copying.

RyanZim avatar Apr 05 '19 22:04 RyanZim

Here's an implementation https://github.com/kellyselden/fs-move/blob/master/src/index.js.

kellyselden avatar Apr 07 '19 19:04 kellyselden