From fbbaa42ee55a7f753f7cab9b1a905ccf73cf26d5 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Tue, 27 Jan 2015 22:26:27 +0200 Subject: Add option to preserve/enforce string quote style `-q 0` (default) use single or double quotes such as to minimize the number of bytes (prefers double quotes when both will do); this is the previous behavior. `-q 1` -- always use single quotes `-q 2` -- always use double quotes `-q 3` or just `-q` -- always use the original quotes. Related codegen option: `quote_style`. Close #495 Close #460 Some `yargs` guru please tell me why `uglifyjs --help` doesn't display the help string for `-q` / `--quotes`, and why it doesn't output the expected argument types anymore, like good old `optimist` did. --- bin/uglifyjs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/uglifyjs b/bin/uglifyjs index 11c3a01a..c9f4c12d 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -66,6 +66,7 @@ You need to pass an argument to this option to specify the name that your module .describe("noerr", "Don't throw an error for unknown options in -c, -b or -m.") .describe("bare-returns", "Allow return outside of functions. Useful when minifying CommonJS modules.") .describe("keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.") + .describe("quotes", "Quote style (0 - auto, 1 - single, 2 - double, 3 - original)") .alias("p", "prefix") .alias("o", "output") @@ -77,6 +78,7 @@ You need to pass an argument to this option to specify the name that your module .alias("r", "reserved") .alias("V", "version") .alias("e", "enclose") + .alias("q", "quotes") .string("source-map") .string("source-map-root") @@ -151,9 +153,14 @@ if (ARGS.r) { if (MANGLE) MANGLE.except = ARGS.r.replace(/^\s+|\s+$/g).split(/\s*,+\s*/); } +if (ARGS.quotes === true) { + ARGS.quotes = 3; +} + var OUTPUT_OPTIONS = { - beautify: BEAUTIFY ? true : false, - preamble: ARGS.preamble || null, + beautify : BEAUTIFY ? true : false, + preamble : ARGS.preamble || null, + quote_style : ARGS.quotes != null ? ARGS.quotes : 0 }; if (ARGS.screw_ie8) { -- cgit v1.2.3