Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict';
|
---|
| 2 | const os = require('os');
|
---|
| 3 |
|
---|
| 4 | const extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/;
|
---|
| 5 | const pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/;
|
---|
| 6 | const homeDir = typeof os.homedir === 'undefined' ? '' : os.homedir();
|
---|
| 7 |
|
---|
| 8 | module.exports = (stack, options) => {
|
---|
| 9 | options = Object.assign({pretty: false}, options);
|
---|
| 10 |
|
---|
| 11 | return stack.replace(/\\/g, '/')
|
---|
| 12 | .split('\n')
|
---|
| 13 | .filter(line => {
|
---|
| 14 | const pathMatches = line.match(extractPathRegex);
|
---|
| 15 | if (pathMatches === null || !pathMatches[1]) {
|
---|
| 16 | return true;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | const match = pathMatches[1];
|
---|
| 20 |
|
---|
| 21 | // Electron
|
---|
| 22 | if (
|
---|
| 23 | match.includes('.app/Contents/Resources/electron.asar') ||
|
---|
| 24 | match.includes('.app/Contents/Resources/default_app.asar')
|
---|
| 25 | ) {
|
---|
| 26 | return false;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | return !pathRegex.test(match);
|
---|
| 30 | })
|
---|
| 31 | .filter(line => line.trim() !== '')
|
---|
| 32 | .map(line => {
|
---|
| 33 | if (options.pretty) {
|
---|
| 34 | return line.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(homeDir, '~')));
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | return line;
|
---|
| 38 | })
|
---|
| 39 | .join('\n');
|
---|
| 40 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.