From 21036a2e67ca9e7c00809bf0f3ebe2f401885dcd Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 2 Jun 2015 15:43:39 +0200 Subject: [PATCH] Fix lines on Node (fix #70). --- source-map-support.js | 14 ++++---------- test.js | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/source-map-support.js b/source-map-support.js index 88c25eb..5074dc5 100644 --- a/source-map-support.js +++ b/source-map-support.js @@ -270,7 +270,7 @@ function cloneCallSite(frame) { return object; } -function wrapCallSite(frame, fromModule) { +function wrapCallSite(frame) { // Most call sites will return the source file from getFileName(), but code // passed to eval() ending in "//# sourceURL=..." will return the source file // from getScriptNameOrSourceURL() instead @@ -281,8 +281,8 @@ function wrapCallSite(frame, fromModule) { // Fix position in Node where some (internal) code is prepended. // See https://github.com/evanw/node-source-map-support/issues/36 - if (fromModule && line === 1) { - column -= 63; + if (line === 1 && !isInBrowser() && !frame.isEval()) { + column -= 62; } var position = mapSourcePosition({ @@ -319,14 +319,8 @@ function prepareStackTrace(error, stack) { sourceMapCache = {}; } - var fromModule = - !isInBrowser() && - stack.length && - stack[stack.length - 1].getFileName() === 'module.js' - ; - return error + stack.map(function(frame) { - return '\n at ' + wrapCallSite(frame, fromModule); + return '\n at ' + wrapCallSite(frame); }).join(''); } diff --git a/test.js b/test.js index 2b54c29..8eab1c4 100644 --- a/test.js +++ b/test.js @@ -228,7 +228,7 @@ it('throw with empty source map', function() { 'throw new Error("test");' ], [ 'Error: test', - /^ at Object\.exports\.test \(.*\/.generated.js:1:96\)$/ + /^ at Object\.exports\.test \(.*\/.generated.js:1:34\)$/ ]); }); @@ -237,7 +237,7 @@ it('throw with source map with gap', function() { 'throw new Error("test");' ], [ 'Error: test', - /^ at Object\.exports\.test \(.*\/.generated.js:1:96\)$/ + /^ at Object\.exports\.test \(.*\/.generated.js:1:34\)$/ ]); });