nfriedly / node-bestzip

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

Redundant ./ in zip package ? #48

Open abcfy2 opened 3 years ago

abcfy2 commented 3 years ago

Here is my test case in my Windows OS:

$ cd dist && bestzip . ../dist.zip

$ cd .. && unzip -l dist.zip
Archive: dist.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
  1468928  2021-08-06 04:53   ./build/Release/libglib-2.0-0.dll
   289792  2021-08-06 04:53   ./build/Release/libgobject-2.0-0.dll
 21130752  2021-08-06 04:53   ./build/Release/libvips-42.dll
   343040  2021-08-06 04:53   ./build/Release/libvips-cpp.dll
   360448  2021-08-06 04:53   ./build/Release/sharp.node
   103780  2021-07-31 05:17   ./fonts/Barlow-Italic.ttf
    98340  2021-07-31 05:17   ./fonts/Barlow-Regular.ttf
      181  2021-07-31 05:17   ./fonts/fonts.conf
   132740  2021-07-31 05:17   ./fonts/SourceCodePro-Regular.otf
   889623  2021-08-06 04:53   ./index.js
  2563398  2021-08-06 04:53   ./index.js.map
    40682  2021-08-06 04:53   ./sourcemap-register.js
     1490  2021-08-06 04:53   ./vendor/8.10.6/include/vips/vips8
  1468928  2021-08-06 04:53   ./vendor/8.10.6/lib/libglib-2.0-0.dll
   317662  2021-08-06 04:53   ./vendor/8.10.6/lib/libglib-2.0.lib
   289792  2021-08-06 04:53   ./vendor/8.10.6/lib/libgobject-2.0-0.dll
    84632  2021-08-06 04:53   ./vendor/8.10.6/lib/libgobject-2.0.lib
 21130752  2021-08-06 04:53   ./vendor/8.10.6/lib/libvips-42.dll
   616376  2021-08-06 04:53   ./vendor/8.10.6/lib/libvips.lib
       11  2021-08-06 04:53   ./vendor/8.10.6/platform.json
     4230  2021-08-06 04:53   ./vendor/8.10.6/THIRD-PARTY-NOTICES.md
      580  2021-08-06 04:53   ./vendor/8.10.6/versions.json
---------                     -------
 51336157                     22 files

And open with 7zip, also contains ./ directory: image

Seems it's a issue only run in powershell or cmd, when I run in msys2 or cygwin, it's OK.

nfriedly commented 3 years ago

If you do ./* instead of ., does that get the behavior you want?

e.g.

$ cd dist && bestzip ./* ../dist.zip

I believe . refers to the entire directory whereas ./* refers to all of the files in the directory.

abcfy2 commented 3 years ago

No, still not workong:

# powershell
$ bestzip ../dist.zip ./*
unzip -l dist.zip

Archive:  dist.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
   889623  2021-08-06 04:53   ./index.js
    40682  2021-08-06 04:53   ./sourcemap-register.js
  2563398  2021-08-06 04:53   ./index.js.map
  1468928  2021-08-06 04:53   ./build/Release/libglib-2.0-0.dll
 21130752  2021-08-06 04:53   ./build/Release/libvips-42.dll
   289792  2021-08-06 04:53   ./build/Release/libgobject-2.0-0.dll
   343040  2021-08-06 04:53   ./build/Release/libvips-cpp.dll
   360448  2021-08-06 04:53   ./build/Release/sharp.node
   103780  2021-07-31 05:17   ./fonts/Barlow-Italic.ttf
      181  2021-07-31 05:17   ./fonts/fonts.conf
    98340  2021-07-31 05:17   ./fonts/Barlow-Regular.ttf
   132740  2021-07-31 05:17   ./fonts/SourceCodePro-Regular.otf
     1490  2021-08-06 04:53   ./vendor/8.10.6/include/vips/vips8
  1468928  2021-08-06 04:53   ./vendor/8.10.6/lib/libglib-2.0-0.dll
   317662  2021-08-06 04:53   ./vendor/8.10.6/lib/libglib-2.0.lib
   289792  2021-08-06 04:53   ./vendor/8.10.6/lib/libgobject-2.0-0.dll
    84632  2021-08-06 04:53   ./vendor/8.10.6/lib/libgobject-2.0.lib
 21130752  2021-08-06 04:53   ./vendor/8.10.6/lib/libvips-42.dll
   616376  2021-08-06 04:53   ./vendor/8.10.6/lib/libvips.lib
       11  2021-08-06 04:53   ./vendor/8.10.6/platform.json
     4230  2021-08-06 04:53   ./vendor/8.10.6/THIRD-PARTY-NOTICES.md
      580  2021-08-06 04:53   ./vendor/8.10.6/versions.json
---------                     -------
 51336157                     22 files

And also ./* cannot match dot file, so it's better to use . not ./*

abcfy2 commented 3 years ago

Oh, I got it, if zip folder use node, this issue will happened.

# Run in Linux machine
$ bestzip --force node ../dist.zip .
Writing . to ../dist.zip...
zipped!

$ unzip -l ../dist.zip
Archive:  ../dist.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
  1468928  2021-08-06 04:53   ./build/Release/libglib-2.0-0.dll
   289792  2021-08-06 04:53   ./build/Release/libgobject-2.0-0.dll
 21130752  2021-08-06 04:53   ./build/Release/libvips-42.dll
   343040  2021-08-06 04:53   ./build/Release/libvips-cpp.dll
   360448  2021-08-06 04:53   ./build/Release/sharp.node
   103780  2021-07-31 05:17   ./fonts/Barlow-Italic.ttf
    98340  2021-07-31 05:17   ./fonts/Barlow-Regular.ttf
      181  2021-07-31 05:17   ./fonts/fonts.conf
   132740  2021-07-31 05:17   ./fonts/SourceCodePro-Regular.otf
   889623  2021-08-06 04:53   ./index.js
  2563398  2021-08-06 04:53   ./index.js.map
    40682  2021-08-06 04:53   ./sourcemap-register.js
     1490  2021-08-06 04:53   ./vendor/8.10.6/include/vips/vips8
  1468928  2021-08-06 04:53   ./vendor/8.10.6/lib/libglib-2.0-0.dll
   317662  2021-08-06 04:53   ./vendor/8.10.6/lib/libglib-2.0.lib
   289792  2021-08-06 04:53   ./vendor/8.10.6/lib/libgobject-2.0-0.dll
    84632  2021-08-06 04:53   ./vendor/8.10.6/lib/libgobject-2.0.lib
 21130752  2021-08-06 04:53   ./vendor/8.10.6/lib/libvips-42.dll
   616376  2021-08-06 04:53   ./vendor/8.10.6/lib/libvips.lib
       11  2021-08-06 04:53   ./vendor/8.10.6/platform.json
     4230  2021-08-06 04:53   ./vendor/8.10.6/THIRD-PARTY-NOTICES.md
      580  2021-08-06 04:53   ./vendor/8.10.6/versions.json
---------                     -------
 51336157                     22 files

But use native, it's working:

$ bestzip --force native ../dist.zip .
Writing . to ../dist.zip...
zipped!

$ unzip -l ../dist.zip
Archive:  ../dist.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2021-08-06 12:53   build/
        0  2021-08-06 12:53   build/Release/
  1468928  2021-08-06 12:53   build/Release/libglib-2.0-0.dll
   289792  2021-08-06 12:53   build/Release/libgobject-2.0-0.dll
 21130752  2021-08-06 12:53   build/Release/libvips-42.dll
   343040  2021-08-06 12:53   build/Release/libvips-cpp.dll
   360448  2021-08-06 12:53   build/Release/sharp.node
        0  2021-08-06 12:53   fonts/
   103780  2021-07-31 13:17   fonts/Barlow-Italic.ttf
    98340  2021-07-31 13:17   fonts/Barlow-Regular.ttf
      181  2021-07-31 13:17   fonts/fonts.conf
   132740  2021-07-31 13:17   fonts/SourceCodePro-Regular.otf
   889623  2021-08-06 12:53   index.js
  2563398  2021-08-06 12:53   index.js.map
    40682  2021-08-06 12:53   sourcemap-register.js
        0  2021-08-06 12:53   vendor/
        0  2021-08-06 12:53   vendor/8.10.6/
        0  2021-08-06 12:53   vendor/8.10.6/include/
        0  2021-08-06 12:53   vendor/8.10.6/include/vips/
     1490  2021-08-06 12:53   vendor/8.10.6/include/vips/vips8
        0  2021-08-06 12:53   vendor/8.10.6/lib/
  1468928  2021-08-06 12:53   vendor/8.10.6/lib/libglib-2.0-0.dll
   317662  2021-08-06 12:53   vendor/8.10.6/lib/libglib-2.0.lib
   289792  2021-08-06 12:53   vendor/8.10.6/lib/libgobject-2.0-0.dll
    84632  2021-08-06 12:53   vendor/8.10.6/lib/libgobject-2.0.lib
 21130752  2021-08-06 12:53   vendor/8.10.6/lib/libvips-42.dll
   616376  2021-08-06 12:53   vendor/8.10.6/lib/libvips.lib
       11  2021-08-06 12:53   vendor/8.10.6/platform.json
     4230  2021-08-06 12:53   vendor/8.10.6/THIRD-PARTY-NOTICES.md
      580  2021-08-06 12:53   vendor/8.10.6/versions.json
---------                     -------
 51336157                     30 files
nfriedly commented 3 years ago

Oof, ok, that sounds like a bug