use directories for structure
This commit is contained in:
52
node_modules/uglify-js/bin/uglifyjs
generated
vendored
52
node_modules/uglify-js/bin/uglifyjs
generated
vendored
@@ -23,12 +23,29 @@ program.parse = undefined;
|
||||
if (process.argv.indexOf("ast") >= 0) program.helpInformation = UglifyJS.describe_ast;
|
||||
else if (process.argv.indexOf("options") >= 0) program.helpInformation = function() {
|
||||
var text = [];
|
||||
var toplevels = [];
|
||||
var padding = "";
|
||||
var options = UglifyJS.default_options();
|
||||
for (var option in options) {
|
||||
text.push("--" + (option == "output" ? "beautify" : option == "sourceMap" ? "source-map" : option) + " options:");
|
||||
text.push(format_object(options[option]));
|
||||
text.push("");
|
||||
for (var name in options) {
|
||||
var option = options[name];
|
||||
if (option && typeof option == "object") {
|
||||
text.push("--" + ({
|
||||
output: "beautify",
|
||||
sourceMap: "source-map",
|
||||
}[name] || name) + " options:");
|
||||
text.push(format_object(option));
|
||||
text.push("");
|
||||
} else {
|
||||
if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
|
||||
toplevels.push([ {
|
||||
keep_fnames: "keep-fnames",
|
||||
nameCache: "name-cache",
|
||||
}[name] || name, option ]);
|
||||
}
|
||||
}
|
||||
toplevels.forEach(function(tokens) {
|
||||
text.push("--" + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
|
||||
});
|
||||
return text.join("\n");
|
||||
};
|
||||
program.option("-p, --parse <options>", "Specify parser options.", parse_js());
|
||||
@@ -36,6 +53,7 @@ program.option("-c, --compress [options]", "Enable compressor/specify compressor
|
||||
program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
|
||||
program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
|
||||
program.option("-b, --beautify [options]", "Beautify output/specify output options.", parse_js());
|
||||
program.option("-O, --output-opts [options]", "Output options (beautify disabled).", parse_js());
|
||||
program.option("-o, --output <file>", "Output file (default STDOUT).");
|
||||
program.option("--comments [filter]", "Preserve copyright comments in the output.");
|
||||
program.option("--config-file <file>", "Read minify() options from JSON file.");
|
||||
@@ -50,16 +68,18 @@ program.option("--self", "Build UglifyJS as a library (implies --wrap UglifyJS)"
|
||||
program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
|
||||
program.option("--timings", "Display operations run time on STDERR.");
|
||||
program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
|
||||
program.option("--validate", "Perform validation during AST manipulations.");
|
||||
program.option("--verbose", "Print diagnostic messages.");
|
||||
program.option("--warn", "Print warning messages.");
|
||||
program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
|
||||
program.option("--reduce-test", "Reduce a standalone `console.log` based test case.");
|
||||
program.arguments("[files...]").parseArgv(process.argv);
|
||||
if (program.configFile) {
|
||||
options = JSON.parse(read_file(program.configFile));
|
||||
if (options.mangle && options.mangle.properties && options.mangle.properties.regex) {
|
||||
options.mangle.properties.regex = UglifyJS.parse(options.mangle.properties.regex, {
|
||||
expression: true
|
||||
}).getValue();
|
||||
}).value;
|
||||
}
|
||||
}
|
||||
if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
|
||||
@@ -72,6 +92,7 @@ if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
|
||||
"mangle",
|
||||
"sourceMap",
|
||||
"toplevel",
|
||||
"validate",
|
||||
"wrap"
|
||||
].forEach(function(name) {
|
||||
if (name in program) {
|
||||
@@ -93,6 +114,10 @@ if (program.beautify) {
|
||||
options.output.beautify = true;
|
||||
}
|
||||
}
|
||||
if (program.outputOpts) {
|
||||
if (program.beautify) fatal("--beautify cannot be used with --output-opts");
|
||||
options.output = typeof program.outputOpts == "object" ? program.outputOpts : {};
|
||||
}
|
||||
if (program.comments) {
|
||||
if (typeof options.output != "object") options.output = {};
|
||||
options.output.comments = typeof program.comments == "string" ? program.comments : "some";
|
||||
@@ -210,7 +235,18 @@ function run() {
|
||||
} catch (ex) {
|
||||
fatal(ex);
|
||||
}
|
||||
var result = UglifyJS.minify(files, options);
|
||||
if (program.reduceTest) {
|
||||
// load on demand - assumes dev tree checked out
|
||||
var reduce_test = require("../test/reduce");
|
||||
var testcase = files[0] || files[Object.keys(files)[0]];
|
||||
var result = reduce_test(testcase, options, {
|
||||
log: print_error,
|
||||
verbose: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
var result = UglifyJS.minify(files, options);
|
||||
}
|
||||
if (result.error) {
|
||||
var ex = result.error;
|
||||
if (ex.name == "SyntaxError") {
|
||||
@@ -323,7 +359,7 @@ function simple_glob(glob) {
|
||||
.replace(/\?/g, "[^/\\\\]") + "$";
|
||||
var mod = process.platform === "win32" ? "i" : "";
|
||||
var rx = new RegExp(pattern, mod);
|
||||
var results = entries.filter(function(name) {
|
||||
var results = entries.sort().filter(function(name) {
|
||||
return rx.test(name);
|
||||
}).map(function(name) {
|
||||
return path.join(dir, name);
|
||||
@@ -370,7 +406,7 @@ function parse_js(flag) {
|
||||
if (!(node instanceof UglifyJS.AST_Sequence)) throw node;
|
||||
|
||||
function to_string(value) {
|
||||
return value instanceof UglifyJS.AST_Constant ? value.getValue() : value.print_to_string({
|
||||
return value instanceof UglifyJS.AST_Constant ? value.value : value.print_to_string({
|
||||
quote_keys: true
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user