MCPcopy Create free account
hub / github.com/donghaxkim/react-rewrite / withTempFile

Function withTempFile

packages/cli/src/__tests__/transform-text.test.ts:8–13  ·  view source on GitHub ↗
(source: string, ext: string = ".tsx")

Source from the content-addressed store, hash-verified

6import * as os from "node:os";
7
8function withTempFile(source: string, ext: string = ".tsx"): string {
9 const tmpDir = os.tmpdir();
10 const filePath = path.join(tmpDir, `test-text-${Date.now()}-${Math.random().toString(36).slice(2, 8)}${ext}`);
11 fs.writeFileSync(filePath, source, "utf-8");
12 return filePath;
13}
14
15function buildTextEditAnchor(originalText: string, newText: string): TextEditAnchor | undefined {
16 if (originalText === newText) return undefined;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected