Skip to content

Commit

Permalink
Improve code frame (#52)
Browse files Browse the repository at this point in the history
* Fix error when generating code frame from native

* Fix off by one line mappings in code frame
  • Loading branch information
marvinhagemeister authored Jul 6, 2020
1 parent 93bc270 commit 3605bb7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ export function cleanStack(str, cwd = process.cwd()) {
stack = frames
.map((frame) => {
// Only show frame for errors in the user's code
if (!nearestFrame && !/node_modules/.test(frame.fileName)) {
if (
!nearestFrame &&
!/node_modules/.test(frame.fileName) &&
frame.type !== 'native'
) {
nearestFrame = frame;
}

Expand Down Expand Up @@ -142,7 +146,7 @@ export function cleanStack(str, cwd = process.cwd()) {
const { fileName, line, column } = nearestFrame;
if (fileName) {
const content = fs.readFileSync(fileName, 'utf-8');
codeFrame = createCodeFrame(content, line, column - 1, {
codeFrame = createCodeFrame(content, line - 1, column - 1, {
before: 2,
after: 2,
});
Expand Down

0 comments on commit 3605bb7

Please sign in to comment.