()
| 61 | }; |
| 62 | |
| 63 | const resolveCallerFilePath = () => { |
| 64 | const packageCandidates = []; |
| 65 | const fallbackCandidates = []; |
| 66 | |
| 67 | for (const callsite of readCallsites()) { |
| 68 | const filePath = readCallsitePath(callsite); |
| 69 | if (!filePath) continue; |
| 70 | if (isInternalCallsite(callsite)) continue; |
| 71 | if (filePath.includes(PACKAGE_SEGMENT)) { |
| 72 | packageCandidates.push(filePath); |
| 73 | continue; |
| 74 | } |
| 75 | fallbackCandidates.push(filePath); |
| 76 | } |
| 77 | |
| 78 | const packageCandidate = packageCandidates[0]; |
| 79 | if (packageCandidate) return packageCandidate; |
| 80 | |
| 81 | const fallbackCandidate = fallbackCandidates[0]; |
| 82 | if (fallbackCandidate) return fallbackCandidate; |
| 83 | |
| 84 | throw new Error("Unable to resolve caller file path."); |
| 85 | }; |
| 86 | |
| 87 | export const getCurrentFilePath = () => resolveCallerFilePath(); |
| 88 |
no test coverage detected