max-mapper / extract-zip

Zip extraction written in pure JavaScript. Extracts a zip into a directory.
BSD 2-Clause "Simplified" License
388 stars 126 forks source link

Extracting ZIPs sometimes makes subfolders and others dont #129

Open BenDOOH opened 2 years ago

BenDOOH commented 2 years ago

Depending on the zip file being extracted, it either makes a subdirectory with the name of the zip file as the folder and put its contents inside there or extracts the contents directly to targeted directory.

I want to control the behaviour across all extracted zips to be either extract everything in the targeted directory as it or make a subfolder of the named zip and push the zip content there. I cant seem to determine if there are optional parameters for this?

From observation, if the extracted zip has sub folders in it, it will then make a folder with the name of the zip and copy it all inside of it. Compared to a zip with no sub folders.

Are there any optional params to force one way of extracting?

drikishuk commented 1 year ago

There is a way around this, log out the entries and you will see a filepath you can use as a 'base'. inside the onEntry callback you can then update the filepaths for all files and replace the name removing the 'base' from it. after extraction you can then check if inside the folder the 'base' path exists and remove it.