ryanmcgrath / wrench-js

Recursive file operations in Node.js
MIT License
435 stars 71 forks source link

Bug with copyDirSyncRecursive and nested directories #22

Closed gjtorikian closed 12 years ago

gjtorikian commented 12 years ago

Let's say I do this command:

copyDirSyncRecursive("./templates/assets", "out/assets");

Then, I do this:

copyDirSyncRecursive("./resources", "out")

I would expect that the call like this just creates a new resources directory under out. And it does--but it also erases the out/assets directory made by the first one. The workaround is to do something like:

var srcDir = "./resources";
copyDirSyncRecursive(srcDir, "out" + "/" + path.basename(srcDir))
ryanmcgrath commented 12 years ago

About to hop on a plane to Portugal but will look into this when I touch down. ;)

Sent from my iPhone

On Mar 1, 2012, at 15:22, Garen Torikianreply@reply.github.com wrote:

Let's say I do this command:

copyDirSyncRecursive("./templates/assets", "out/assets");

Then, I do this:

copyDirSyncRecursive("./resources", "out")

I would expect that the call like this just creates a new resources directory under out. And it does--but it also erases the out/assets directory made by the first one. The workaround is to do something like:

var srcDir = "./resources";
copyDirSyncRecursive(srcDir, "out" + "/" + path.basename(srcDir))

Reply to this email directly or view it on GitHub: https://github.com/ryanmcgrath/wrench-js/issues/22

mergenchik commented 12 years ago

There is no issue I think, problem is that it was not documented that copyDirSyncRecursive accepts options, where if you pass {preserve: true} as third argument it will not delete target directory before copying.

ryanmcgrath commented 12 years ago

Hmmm, yes, I think you're right. I'm going to close this for now, will update docs shortly to note this.