kangax / html-minifier

Javascript-based HTML compressor/minifier (with Node.js support)
http://kangax.github.io/html-minifier/
MIT License
4.92k stars 568 forks source link

html-minifier Creates a New Directory When One With The Specified Name Already Exists #1116

Open R4356th opened 2 years ago

R4356th commented 2 years ago

If the specified output-dir already exists when using the CLI, it creates a new directory with that name and puts minified versions of the input (making sure to update the copy in the already existing directory as well). While a straightforward workaround is to just ignore the duplicate directory in VCS, it is not ideal and not even an option for those who do not use any VCS. See also #1062).

Devilbinder commented 10 months ago

Can confirm this behaviour. It will reclusively create folders in folders.

Windows 11 Using version V4.0.0

Command used.

html-minifier --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true --input-dir source/path/to/pages --output-dir source/path/to/pages/mini --file-ext html 

This results in a directory structure:

-pages
--mini
---output files

On the next run

-pages
--mini
---mini
----output files

Each run will create a mini sub directory in the previous mini sub directory.