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

Flag to make recursive directory find optional #165

Closed davidwolfpaw closed 6 years ago

davidwolfpaw commented 6 years ago

Thanks for the CLI tool!

I think that it would be useful to have a flag to choose whether or not you recurse through directories to find images. There are times that I would like to optimize a folder, but not the subfolders.

JamieMason commented 6 years ago

Thanks @davidwolfpaw.

This is missing from the examples but the following should work, given this folder structure:

.
├── README.md
├── images
│   ├── sub-dir
│   │   └── no-thanks.png
│   └── yes-please.jpg

You could run the following to only optimise images/yes-please.jpg and not images/sub-dir/no-thanks.png.

imageoptim 'images/*.*'

Internally, ImageOptim-CLI uses https://github.com/isaacs/node-glob#glob-primer.

Please let me know if this works out.

JamieMason commented 6 years ago

Please reopen if you still need anything, thanks.