aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRichard van Velzen <rvanvelzen@expert-shops.com>2012-11-14 14:04:47 +0100
committerMihai Bazon <mihai@bazon.net>2012-11-14 15:30:18 +0200
commite98119496a3d22f2d7ddc5f686eb8edfe05704ad (patch)
tree9a19868e6faee72468b2023e0bfa6964ddd766a7 /lib
parentbdfcbf496b1b7be16dfd8a55c72bad8e5a33cf82 (diff)
downloadtracifyjs-e98119496a3d22f2d7ddc5f686eb8edfe05704ad.tar.gz
tracifyjs-e98119496a3d22f2d7ddc5f686eb8edfe05704ad.zip
Add support for somewhat preserving line numbers.
Usage: uglifyjs2 -b "beautify=0,preserve_line=1" /path/to/js ref #46
Diffstat (limited to 'lib')
-rw-r--r--lib/output.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/output.js b/lib/output.js
index 7309737f..8f43245a 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -59,7 +59,8 @@ function OutputStream(options) {
source_map : null,
bracketize : false,
semicolons : true,
- comments : false
+ comments : false,
+ preserve_line : false
}, true);
var indentation = 0;
@@ -154,6 +155,18 @@ function OutputStream(options) {
might_need_semicolon = false;
maybe_newline();
}
+
+ if (!options.beautify && options.preserve_line && stack[stack.length - 1]) {
+ var target_line = stack[stack.length - 1].start.line;
+ while (current_line < target_line) {
+ OUTPUT += "\n";
+ current_pos++;
+ current_line++;
+ current_col = 0;
+ might_need_space = false;
+ }
+ }
+
if (might_need_space) {
var prev = last_char();
if ((is_identifier_char(prev)