Skip to content

Commit 650e63c

Browse files
authored
improve usability (#5753)
1 parent 59e3855 commit 650e63c

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

bin/uglifyjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ if (typeof options.sourceMap == "object" && "base" in options.sourceMap) {
272272
if (specified["self"]) {
273273
if (paths.length) UglifyJS.AST_Node.warn("Ignoring input files since --self was passed");
274274
if (!options.wrap) options.wrap = "UglifyJS";
275+
if (!("toplevel" in options)) options.toplevel = false;
275276
paths = UglifyJS.FILES;
276277
} else if (paths.length) {
277278
paths = simple_glob(paths);

lib/parse.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ function JS_Parse_Error(message, filename, line, col, pos) {
207207
this.line = line;
208208
this.col = col;
209209
this.pos = pos;
210-
configure_error_stack(this, new SyntaxError(message, filename, line, col));
210+
try {
211+
throw new SyntaxError(message, filename, line, col);
212+
} catch (cause) {
213+
configure_error_stack(this, cause);
214+
}
211215
}
212216
JS_Parse_Error.prototype = Object.create(SyntaxError.prototype);
213217
JS_Parse_Error.prototype.constructor = JS_Parse_Error;

lib/utils.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ function configure_error_stack(ex, cause) {
6565
var msg = "" + cause.message;
6666
cause = null;
6767
var index = stack.indexOf(msg);
68-
if (index >= 0) index += msg.length;
69-
index = stack.indexOf("\n", index) + 1;
68+
if (index < 0) {
69+
index = 0;
70+
} else {
71+
index += msg.length;
72+
index = stack.indexOf("\n", index) + 1;
73+
}
7074
stack = stack.slice(0, index) + stack.slice(stack.indexOf("\n", index) + 1);
7175
}
7276
return stack;
@@ -77,7 +81,11 @@ function configure_error_stack(ex, cause) {
7781
function DefaultsError(msg, defs) {
7882
this.message = msg;
7983
this.defs = defs;
80-
configure_error_stack(this, new Error(msg));
84+
try {
85+
throw new Error(msg);
86+
} catch (cause) {
87+
configure_error_stack(this, cause);
88+
}
8189
}
8290
DefaultsError.prototype = Object.create(Error.prototype);
8391
DefaultsError.prototype.constructor = DefaultsError;

0 commit comments

Comments
 (0)