Skip to content

Commit dc0f1fb

Browse files
authored
Remove dependency on callsites (#172)
1 parent 8a45f01 commit dc0f1fb

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

cucumber-tsflow/package-lock.json

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cucumber-tsflow/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"url": "https://github.com/timjroberts/cucumber-js-tsflow.git"
2727
},
2828
"dependencies": {
29-
"callsites": "^4.2.0",
3029
"log4js": "^6.3.0",
3130
"source-map-support": "^0.5.19",
3231
"underscore": "^1.8.3"

cucumber-tsflow/src/our-callsite.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import callsites from "callsites";
21
// @ts-ignore
32
import * as sourceMapSupport from "source-map-support";
43

@@ -39,3 +38,20 @@ export class Callsite {
3938
return `${this.filename}:${this.lineNumber}`;
4039
}
4140
}
41+
42+
function callsites() {
43+
const _prepareStackTrace = Error.prepareStackTrace;
44+
try {
45+
let result: NodeJS.CallSite[] = [];
46+
Error.prepareStackTrace = (_, callSites) => {
47+
const callSitesWithoutCurrent = callSites.slice(1);
48+
result = callSitesWithoutCurrent;
49+
return callSitesWithoutCurrent;
50+
};
51+
52+
new Error().stack; // eslint-disable-line unicorn/error-message, no-unused-expressions
53+
return result;
54+
} finally {
55+
Error.prepareStackTrace = _prepareStackTrace;
56+
}
57+
}

0 commit comments

Comments
 (0)