diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-04-19 04:27:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 04:27:13 +0800 |
commit | b4b9305db0d3c4682848ed0a4214f1fee332a078 (patch) | |
tree | 487db01afdbe5d9b00225d22ea599cbbf46b6489 /bin | |
parent | 28cfb65c47e7a2adeec35d8a78dd8bb0cf06af12 (diff) | |
download | tracifyjs-b4b9305db0d3c4682848ed0a4214f1fee332a078.tar.gz tracifyjs-b4b9305db0d3c4682848ed0a4214f1fee332a078.zip |
fix parser bugs & CLI reporting (#1827)
fixes #1825
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/uglifyjs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/bin/uglifyjs b/bin/uglifyjs index f31529b0..e89b68a7 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -190,19 +190,19 @@ function run() { if (ex instanceof UglifyJS.JS_Parse_Error) { console.error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col); var col = ex.col; - var line = files[ex.filename].split(/\r?\n/)[ex.line - (col ? 1 : 2)]; + var lines = files[ex.filename].split(/\r?\n/); + var line = lines[ex.line - 1]; + if (!line && !col) { + line = lines[ex.line - 2]; + col = line.length; + } if (line) { if (col > 40) { line = line.slice(col - 40); col = 40; } - if (col) { - console.error(line.slice(0, 80)); - console.error(line.slice(0, col).replace(/\S/g, " ") + "^"); - } else { - console.error(line.slice(-40)); - console.error(line.slice(-40).replace(/\S/g, " ") + "^"); - } + console.error(line.slice(0, 80)); + console.error(line.slice(0, col).replace(/\S/g, " ") + "^"); } } fatal("ERROR: " + ex.message); |