Skip to content

Commit

Permalink
longer path for call stack
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro5id committed Dec 12, 2019
1 parent e7dba03 commit 31b749d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/format-stack-trace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import appRootPath from 'app-root-path';
import * as path from 'path';

export class FormatStackTrace {
public static readonly divider = ' at';
Expand All @@ -14,7 +15,7 @@ export class FormatStackTrace {
// this filters out lines relating to this package when referenced from other projects
const linesWithoutLocalFiles = lines.filter(m => m.match(/node_modules\/.*console-log-json\/.*/gi) == null);
// noinspection UnnecessaryLocalVariableJS
const linesWithoutFullPath = linesWithoutLocalFiles.map(m => m.replace(appRootPath.toString(), ''));
const linesWithoutFullPath = linesWithoutLocalFiles.map(m => m.replace(path.join(appRootPath.toString(), '..'), ''));
return linesWithoutFullPath;
}
}
3 changes: 2 additions & 1 deletion src/get-calling-filename.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import appRootPath from 'app-root-path';
import callsites from 'callsites';
import * as path from 'path';

export function getCallingFilename(): string | null {
const callsitesList = callsites();
const callsite = callsitesList[3];
let name: string | null = callsite.getFileName();
if (name) {
name = name.replace(appRootPath.toString(), '');
name = name.replace(path.join(appRootPath.toString(), '..'), '');
}
return name;
}

0 comments on commit 31b749d

Please sign in to comment.