nfriedly / node-bestzip

Provides a `bestzip` command that uses the system `zip` if avaliable, and a Node.js implimentation otherwise.
MIT License
80 stars 16 forks source link

Is there a way to keep the directories inside of the zip file? #17

Closed micronaut closed 6 years ago

micronaut commented 6 years ago

I am trying to zip up several files and directories. I would like to keep the directory structure so that when the zip file is unzipped the directories are recreated.

Is this possible to do?

nfriedly commented 6 years ago

I'm sure it's possible, but this library needs some work to get back in shape :/

Lampei commented 6 years ago

Doesn't it already do this? This line should do recursion in the native method https://github.com/nfriedly/node-bestzip/blob/master/lib/bestzip.js#L37 And this line should do the recursion in the non-native method https://github.com/nfriedly/node-bestzip/blob/zip-symlinked-folders/lib/bestzip.js#L69

I seemed to recall in my usage that it dropped down to the sub folders also. The only thing that was fixed (and it still in a branch awaiting testing) is for sym-linked folders not working correctly.

micronaut commented 6 years ago

@Lampei It does seem to recursively extract files and add them to the zip file, but it is not adding the directories to the zip file. The zip file is flattened. I saw the expand option being passed to archiver, which I thought would add the directories, but this is not happening.

nfriedly commented 6 years ago

OK, I just released v2.0.0, and I believe it should now behave the way you want. Please try it out and let me know.

micronaut commented 6 years ago

@nfriedly Thanks for the update. I ended up using an alternative that is working for now.