MCPcopy Create free account
hub / github.com/expo/expo / applyTransformsOnFileContentAsync

Function applyTransformsOnFileContentAsync

tools/src/Transforms.ts:42–61  ·  view source on GitHub ↗
(
  filePath: string,
  transforms: FileTransform[]
)

Source from the content-addressed store, hash-verified

40}
41
42async function applyTransformsOnFileContentAsync(
43 filePath: string,
44 transforms: FileTransform[]
45): Promise<{
46 content: string;
47 transformsUsed: Set<FileTransform>;
48}> {
49 // Transform source content.
50 let result = await fs.readFile(filePath, 'utf8');
51 const transformsUsed = new Set<FileTransform>();
52 for (const transform of transforms) {
53 const beforeTransformation = result;
54 result = applySingleTransform(result, transform);
55 await maybePrintDebugInfoAsync(beforeTransformation, result, filePath, transform);
56 if (result !== beforeTransformation) {
57 transformsUsed.add(transform);
58 }
59 }
60 return { content: result, transformsUsed };
61}
62
63/**
64 * Filters file contents transformations to only these that match path patterns.

Callers 2

transformFilesAsyncFunction · 0.85

Calls 3

applySingleTransformFunction · 0.85
maybePrintDebugInfoAsyncFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…