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

Couldn't create archive on top level #42

Open pingwin4ik opened 3 years ago

pingwin4ik commented 3 years ago

cd build/ && bestzip ../build.zip * not working this feature: (This will not include the build/ folder, it's contents will be top-level.) version 2.1.7

Thank you!

Lampei commented 3 years ago

You're not at the top level though. You changed directory to be the build directory.

If you want the build directory to be included, wouldn't you do bestzip ./build/build.zip * ?

nfriedly commented 3 years ago

@pingwin4ik what OS are you on, and what tool are you using to extract the .zip files?

Some extraction tools automatically add a grouping folder when there are multiple top-level files. The one built into macOS does, for example. However if you use a tool to inspect the .zip without extracting it such as https://extract.me/ it should show things as expected.

For example, I made these two .zip files from the test/ directory:

On my macbook, fixtures-with-folder.zip extracts to a folder named fixtures/ as expected, but fixtures-without-folder.zip extracts to a folder named fixtures-without-folder/ - this was not part of the .zip file, the mac Archive Utility created that folder based on the name of the .zip file.

I also tested the above with --force=node and got identical results.

pingwin4ik commented 3 years ago

You're not at the top level though. You changed directory to be the build directory.

If you want the build directory to be included, wouldn't you do bestzip ./build/build.zip * ?

Thank you for response ;=) We try to run in azure pipeline and we want archive all files in folder "build" without folder we run next command: "cd build/ && bestzip ../archive.zip *"

P.S. run in Ubuntu 16 04 as runner on Azure and then publish to bucket

adeviss2 commented 3 years ago

The problem is that when you use "*" it doesn't zip .dot files like .htaccess.

I want to zip for example the dist folder but in the archive I dont want a dist folder , I need to be top level so: I do: cd dist && bestzip ../dist.zip && cd ../ it gives an error when I do: "cd dist && bestzip ../dist.zip ./ && cd ../" it's all got except no htaccess file

nfriedly commented 3 years ago

I think that later version should include the dotfiles.. what happens with a native zip command?

Alternatively, does it work if you include them explicitly? cd dist && bestzip ../dist.zip ./ .htaccess && cd ../