MCPcopy Create free account
hub / github.com/vercel/vercel / readFile

Function readFile

packages/python-analysis/src/wasm/host-utils.ts:37–50  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

35export function createHostUtils() {
36 return {
37 readFile(path: string): string {
38 const ctx = readFileStorage.getStore();
39 if (ctx?.readFile) {
40 const relative = stripWorkingDir(path, ctx.workingDir);
41 if (relative != null) {
42 const result = ctx.readFile(relative);
43 if (result != null) return result;
44 }
45 }
46 // No readFile callback or it returned null -- do not fall through to
47 // readFileSync because the WASM module could request arbitrary host
48 // paths (e.g. via `-r /etc/passwd` in requirements.txt).
49 throw new WitResultError(`File not found: ${path}`);
50 },
51 domainToAscii(domain: string): string {
52 try {
53 // Use the WHATWG URL parser for IDNA2008 conversion.

Callers 6

getCoreModuleFunction · 0.70
probe.jsFile · 0.50
generateBundleMethod · 0.50
readDistInfoFileFunction · 0.50
extendDistRecordFunction · 0.50
readFileIfExistsFunction · 0.50

Calls 1

stripWorkingDirFunction · 0.85

Tested by

no test coverage detected