Skip to content

Commit

Permalink
[FIX]: Module source row
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasszoke committed May 30, 2018
1 parent 20b35d6 commit a0f671e
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions index.js
Expand Up @@ -127,9 +127,33 @@ function eyecatcher() {

const trace = new Error().stack;
const regexp = /\.<anonymous>(.*)\n/g;
const regexpModule = /\module.exports(.*)\n/g;
let source;

try {

source = regexpModule.exec(trace)[1];

} catch(error) {

try {

let source = regexp.exec(trace)[1];
source = source.replace(/^.*[\\\/]/, '').replace(/[{()}]/g, '').replace(/\n|\r/g, "");
source = regexp.exec(trace)[1];

} catch(error) {

source = null;
};
};

if (source) {

source = source.replace(/^.*[\\\/]/, '').replace(/[{()}]/g, '').replace(/\n|\r/g, "");

} else {

source = 'Row not found!';
};

return ' ' + source;
};
Expand Down

0 comments on commit a0f671e

Please sign in to comment.