diff options
author | Tristian Flanagan <tflanagan@datacollaborative.com> | 2015-09-14 18:26:59 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2015-11-20 16:26:24 -0500 |
commit | dfee4e3712ac4673b5fc472a8f77ac65bdc65f87 (patch) | |
tree | 143fd17bf90eaa8fec46ee72c4b1705de20f2d38 /lib/module.js | |
parent | 94c3507f5c66a2c2da24591f9b28867465918675 (diff) | |
download | android-node-v8-dfee4e3712ac4673b5fc472a8f77ac65bdc65f87.tar.gz android-node-v8-dfee4e3712ac4673b5fc472a8f77ac65bdc65f87.tar.bz2 android-node-v8-dfee4e3712ac4673b5fc472a8f77ac65bdc65f87.zip |
module: fix column offsets in errors
Because Node modules are wrapped, errors on the first line
of a file leak the wrapper to the user and report the wrong
column number. This commit adds a line break to the module
wrapper so that the first line is treated the same as all
other lines. To compensate for the additional line, a line
offset of -1 is also applied to errors.
Fixes: https://github.com/nodejs/node/issues/2860
PR-URL: https://github.com/nodejs/node/pull/2867
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib/module.js')
-rw-r--r-- | lib/module.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/module.js b/lib/module.js index 507ca83c1b..8b9b59551e 100644 --- a/lib/module.js +++ b/lib/module.js @@ -47,7 +47,6 @@ Module.wrapper = NativeModule.wrapper; Module.wrap = NativeModule.wrap; Module._debug = util.debuglog('module'); - // We use this alias for the preprocessor that filters it out const debug = Module._debug; @@ -401,7 +400,8 @@ Module.prototype._compile = function(content, filename) { // create wrapper function var wrapper = Module.wrap(content); - var compiledWrapper = runInThisContext(wrapper, { filename: filename }); + var compiledWrapper = runInThisContext(wrapper, + { filename: filename, lineOffset: -1 }); if (global.v8debug) { if (!resolvedArgv) { // we enter the repl if we're not given a filename argument. |