html-minifier icon indicating copy to clipboard operation
html-minifier copied to clipboard

fix config file: "html5" and "includeAutoGeneratedTags" were ignored

Open bulk88 opened this issue 4 years ago • 3 comments

the fix for #860 enabled disabling these 2 flags from the command line but also made them uncontrollable from the JSON config file

old commander.js (not 2021 commander.js) assigns boolean true unconditionally as defaultValue for all --no- arguments, when minifier fuses command line and JSON config file options together in cli.js's createOptions(), it sees program["includeAutoGeneratedTags"] = true and ignored config["includeAutoGeneratedTags"], in my case "= false". Delete the defaultValue/key from commander.js object before parsing user's ARGV to solve the bug.

EXTRA NOTES this probably fixes https://github.com/kangax/html-minifier/issues/1045

work around for old/publish html-minifiers is to always put --no-include-auto-generated-tags on cmd line in addition to "includeAutoGeneratedTags": false in json config file

bulk88 avatar Apr 14 '21 08:04 bulk88

Would be great to have this PR at https://github.com/terser/html-minifier-terser too =)

DanielRuf avatar May 19 '21 11:05 DanielRuf

@bulk88 does this apply to the latest commander too? I'm wondering because the plan is to update all deps to the latest version.

XhmikosR avatar Oct 10 '21 15:10 XhmikosR

I don't know. commander module from 10 years ago and 2021 commander module have almost no source code in common by now when I debugged this/wrote the patch and there was no attempt at back (bug) compat by commander's authors IIRC.

bulk88 avatar Oct 10 '21 19:10 bulk88