MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / mapDistFileToSource

Function mapDistFileToSource

packages/testkit/src/snapshot.ts:80–93  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

78}
79
80function mapDistFileToSource(filePath: string): string {
81 const normalized = path.normalize(filePath);
82 const marker = `${path.sep}dist${path.sep}`;
83 const markerIndex = normalized.lastIndexOf(marker);
84 if (markerIndex < 0) return normalized;
85
86 const before = normalized.slice(0, markerIndex);
87 const after = normalized.slice(markerIndex + marker.length);
88 const sourceLike = `${before}${path.sep}src${path.sep}${after}`;
89 const sourceTs = sourceLike.replace(/\.(?:c|m)?js$/u, ".ts");
90 if (existsSync(sourceTs)) return sourceTs;
91 if (existsSync(sourceLike)) return sourceLike;
92 return normalized;
93}
94
95function resolveSnapshotFile(name: string, opts: SnapshotMatchOptions | undefined): string {
96 const cwd = opts?.cwd ?? process.cwd();

Callers 1

resolveSnapshotFileFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected