JamieMason / ImageOptim-CLI

Make optimisation of images part of your automated build process
https://foldleft.io/image-tools
MIT License
3.45k stars 125 forks source link

Supported file types are case sensitive #181

Closed jamesstout closed 4 years ago

jamesstout commented 4 years ago

Steps To Reproduce The Error

A dir with *.PNG files:

james@Jamess-iMac: ~/Desktop/project-burrito
$ ll
total 203008
-rwxrwxrwx@ 1 james  staff  11865040 Feb 26  2019 IMG_4111.PNG
-rwxrwxrwx@ 1 james  staff   6949340 Jun 20 18:50 IMG_4413.PNG
-rwxrwxrwx@ 1 james  staff  14562646 Jun 20 18:49 IMG_4488.PNG
-rwxrwxrwx@ 1 james  staff   7283045 Jun 20 18:49 IMG_4558.PNG
-rwxrwxrwx@ 1 james  staff   7448514 Jun 20 18:49 IMG_4564.PNG
-rwxrwxrwx@ 1 james  staff   9694620 Jun 20 18:49 IMG_4609.PNG
-rwxrwxrwx@ 1 james  staff   8287775 Jun 20 18:49 IMG_4709.PNG
-rwxrwxrwx@ 1 james  staff  13382413 Jun 20 18:48 IMG_4771.PNG
-rwxrwxrwx@ 1 james  staff   8238668 Jun 20 18:46 IMG_5013.PNG
-rwxrwxrwx@ 1 james  staff   8226910 Jun 20 18:46 IMG_5090.PNG
-rwxrwxrwx@ 1 james  staff   7977126 Jun 20 18:46 IMG_5122.PNG

Expected Behaviour

imageoptim should find the *.PNG files and process them. --help says:

Run ImageAlpha.app and ImageOptim.app over every PNG in current directory imageoptim --imagealpha '*/.png'

This command doesn't find files with an uppercase extension.

Actual Behaviour

james@Jamess-iMac: ~/Desktop/project-burrito
$ imageoptim --imagealpha '**/*.png'
! No images matched the patterns provided

james@Jamess-iMac: ~/Desktop/project-burrito
$ imageoptim --imagealpha '**/*.PNG'
! No images matched the patterns provided

If I rename, then it works:

james@Jamess-iMac: ~/Desktop/project-burrito
$ for file in *.PNG
> do
> mv "$file" "${file%.PNG}.png"
> done

james@Jamess-iMac: ~/Desktop/project-burrito
$ ll
total 203008
-rwxrwxrwx@ 1 james  staff  11865040 Feb 26  2019 IMG_4111.png
-rwxrwxrwx@ 1 james  staff   6949340 Jun 20 18:50 IMG_4413.png
-rwxrwxrwx@ 1 james  staff  14562646 Jun 20 18:49 IMG_4488.png
-rwxrwxrwx@ 1 james  staff   7283045 Jun 20 18:49 IMG_4558.png
-rwxrwxrwx@ 1 james  staff   7448514 Jun 20 18:49 IMG_4564.png
-rwxrwxrwx@ 1 james  staff   9694620 Jun 20 18:49 IMG_4609.png
-rwxrwxrwx@ 1 james  staff   8287775 Jun 20 18:49 IMG_4709.png
-rwxrwxrwx@ 1 james  staff  13382413 Jun 20 18:48 IMG_4771.png
-rwxrwxrwx@ 1 james  staff   8238668 Jun 20 18:46 IMG_5013.png
-rwxrwxrwx@ 1 james  staff   8226910 Jun 20 18:46 IMG_5090.png
-rwxrwxrwx@ 1 james  staff   7977126 Jun 20 18:46 IMG_5122.png

james@Jamess-iMac: ~/Desktop/project-burrito
$ imageoptim --imagealpha '**/*.png'
i Running ImageAlpha...
i Running ImageOptim...
✓ IMG_4111.png was: 11.9MB now: 1.04MB saving: 10.8MB (91.24%)
---8<---8<---snip---8<---8<---8<---8<
✓ TOTAL was: 104MB now: 8.76MB saving: 95.2MB (91.57%)
✓ Finished

Version Numbers or N/A

$ bash --version
GNU bash, version 5.0.11(1)-release (x86_64-apple-darwin17.7.0)

Also, my filesystem is case-insensitive:

$ diskutil info / | grep Personality
   File System Personality:  APFS

Available APFS personalities:

$ diskutil listFilesystems | grep APFS
APFS                            APFS
  (or) APFSI
Case-sensitive APFS             APFS (Case-sensitive)

Help Needed

Do we add uppercase file types to the supports hash? (or map or indexable object or whatever it's called in TypeScript) - seems a bit hacky.

Or use .toLowerCase() somewhere? Maybe in the extname() call in is-supported.ts

[I'm trying this out in my fork, but, the nexe compiled bin just exits:

james@Jamess-iMac: ~/tmp/ImageOptim-CLI/dist on master[!]
$ ./imageoptim
Killed: 9

Can you run/debug without building with nexe?

JamieMason commented 4 years ago

Can you run/debug without building with nexe?

Sorry, try this @jamesstout to skip Nexe

npm run build:ts
node dist/imageoptim.js --help
JamieMason commented 4 years ago

Fix available and will be in the next release.