parent
c55dd5ed74
commit
1175ed8c51
23
bin/uglifyjs
23
bin/uglifyjs
|
|
@ -9,6 +9,7 @@ var yargs = require("yargs");
|
|||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var async = require("async");
|
||||
var exit = require("exit");
|
||||
var acorn;
|
||||
var ARGS = yargs
|
||||
.usage("$0 input1.js [input2.js ...] [options]\n\
|
||||
|
|
@ -144,18 +145,18 @@ if (ARGS.noerr) {
|
|||
if (ARGS.version || ARGS.V) {
|
||||
var json = require("../package.json");
|
||||
print(json.name + ' ' + json.version);
|
||||
process.exit(0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (ARGS.ast_help) {
|
||||
var desc = UglifyJS.describe_ast();
|
||||
print(typeof desc == "string" ? desc : JSON.stringify(desc, null, 2));
|
||||
process.exit(0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (ARGS.h || ARGS.help) {
|
||||
print(yargs.help());
|
||||
process.exit(0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (ARGS.acorn) {
|
||||
|
|
@ -283,12 +284,12 @@ if (files.length == 0) {
|
|||
|
||||
if (files.indexOf("-") >= 0 && ARGS.source_map) {
|
||||
print_error("ERROR: Source map doesn't work with input from STDIN");
|
||||
process.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (files.filter(function(el){ return el == "-" }).length > 1) {
|
||||
print_error("ERROR: Can read a single file from STDIN (two or more dashes specified)");
|
||||
process.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
var STATS = {};
|
||||
|
|
@ -313,7 +314,7 @@ try {
|
|||
print_error(ex.msg);
|
||||
print_error("Supported options:");
|
||||
print_error(sys.inspect(ex.defs));
|
||||
process.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -321,7 +322,7 @@ async.eachLimit(files, 1, function (file, cb) {
|
|||
read_whole_file(file, function (err, code) {
|
||||
if (err) {
|
||||
print_error("ERROR: can't read file: " + file);
|
||||
process.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
if (ARGS.p != null) {
|
||||
if (P_RELATIVE) {
|
||||
|
|
@ -360,7 +361,7 @@ async.eachLimit(files, 1, function (file, cb) {
|
|||
print_error("Parse error at " + file + ":" + ex.line + "," + ex.col);
|
||||
print_error(ex.message);
|
||||
print_error(ex.stack);
|
||||
process.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
|
|
@ -397,7 +398,7 @@ async.eachLimit(files, 1, function (file, cb) {
|
|||
regex = ARGS.mangle_regex ? extractRegex(ARGS.mangle_regex) : null;
|
||||
} catch (e) {
|
||||
print_error("ERROR: Invalid --mangle-regex: " + e.message);
|
||||
process.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
TOPLEVEL = UglifyJS.mangle_properties(TOPLEVEL, {
|
||||
|
|
@ -512,7 +513,7 @@ function getOptions(flag, constants) {
|
|||
} catch(ex) {
|
||||
if (ex instanceof UglifyJS.JS_Parse_Error) {
|
||||
print_error("Error parsing arguments for flag `" + flag + "': " + x);
|
||||
process.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
ast.walk(new UglifyJS.TreeWalker(function(node){
|
||||
|
|
@ -532,7 +533,7 @@ function getOptions(flag, constants) {
|
|||
}
|
||||
print_error(node.TYPE)
|
||||
print_error("Error parsing arguments for flag `" + flag + "': " + x);
|
||||
process.exit(1);
|
||||
exit(1);
|
||||
}));
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"async": "~0.2.6",
|
||||
"exit": "~0.1.2",
|
||||
"source-map": "~0.5.1",
|
||||
"uglify-to-browserify": "~1.0.0",
|
||||
"yargs": "~3.10.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
var Mocha = require('mocha'),
|
||||
fs = require('fs'),
|
||||
path = require('path');
|
||||
path = require('path'),
|
||||
exit = require('exit');
|
||||
|
||||
// Instantiate a Mocha instance.
|
||||
var mocha = new Mocha({});
|
||||
|
|
@ -22,7 +23,7 @@ module.exports = function() {
|
|||
mocha.run(function(failures) {
|
||||
if (failures !== 0) {
|
||||
process.on('exit', function () {
|
||||
process.exit(failures);
|
||||
exit(failures);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ var U = require("../tools/node");
|
|||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
var assert = require("assert");
|
||||
var exit = require("exit");
|
||||
|
||||
var tests_dir = path.dirname(module.filename);
|
||||
var failures = 0;
|
||||
|
|
@ -13,7 +14,7 @@ run_compress_tests();
|
|||
if (failures) {
|
||||
console.error("\n!!! Failed " + failures + " test cases.");
|
||||
console.error("!!! " + Object.keys(failed_files).join(", "));
|
||||
process.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
var mocha_tests = require("./mocha.js");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user