Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
fix: call of tryGetStackInfo() in DependsOn()
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Kloubert committed Feb 9, 2024
1 parent c4163b3 commit b671a93
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egomobile/documentation",
"version": "0.7.0",
"version": "0.7.1",
"description": "Tools for documenting (TypeScript) code.",
"main": "lib/index.js",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/decorators/DependsOn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function DependsOn(
const createDependsOnHelpers: CreateDependsOnHelpersFunc = require("../utils/internal").createDependsOnHelpers;
const tryGetStackInfo = require("../utils/internal").tryGetStackInfo;

const stackInfo: Nullable<IStackInfo | false> = tryGetStackInfo();
const stackInfo: Nullable<IStackInfo | false> = tryGetStackInfo(1);

const {
addItem
Expand Down
4 changes: 2 additions & 2 deletions src/utils/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ export function isNil(val: unknown): val is (null | undefined) {
return typeof val === "undefined" || val === null;
}

export function tryGetStackInfo(): Nullable<IStackInfo | false> {
export function tryGetStackInfo(offset = 0): Nullable<IStackInfo | false> {
try {
const stackTrace = new Error().stack;

if (stackTrace) {
const stackTraceLines = stackTrace.split("\n");
const callerLine = stackTraceLines[2];
const callerLine = stackTraceLines[2 + offset];
if (callerLine) {
const fileAndLineRegex = /\(?([^\s]+):(\d+):\d+\)?$/i;
const match = fileAndLineRegex.exec(callerLine);
Expand Down

0 comments on commit b671a93

Please sign in to comment.