MCPcopy
hub / github.com/facebook/react / readInputFixtures

Function readInputFixtures

compiler/packages/snap/src/fixture-utils.ts:102–140  ·  view source on GitHub ↗
(
  rootDir: string,
  filter: TestFilter | null,
)

Source from the content-addressed store, hash-verified

100 };
101
102async function readInputFixtures(
103 rootDir: string,
104 filter: TestFilter | null,
105): Promise<Map<string, {value: string; filepath: string}>> {
106 let inputFiles: Array<string>;
107 if (filter == null) {
108 inputFiles = glob.sync(`**/*{${INPUT_EXTENSIONS.join(',')}}`, {
109 cwd: rootDir,
110 });
111 } else {
112 inputFiles = (
113 await Promise.all(
114 filter.paths.map(pattern =>
115 glob.glob(`${pattern}{${INPUT_EXTENSIONS.join(',')}}`, {
116 cwd: rootDir,
117 }),
118 ),
119 )
120 ).flat();
121 }
122 const inputs: Array<Promise<[string, {value: string; filepath: string}]>> =
123 [];
124 for (const filePath of inputFiles) {
125 // Do not include extensions in unique identifier for fixture
126 const partialPath = stripExtension(filePath, INPUT_EXTENSIONS);
127 inputs.push(
128 fs.readFile(path.join(rootDir, filePath), 'utf8').then(input => {
129 return [
130 partialPath,
131 {
132 value: input,
133 filepath: filePath,
134 },
135 ];
136 }),
137 );
138 }
139 return new Map(await Promise.all(inputs));
140}
141async function readOutputFixtures(
142 rootDir: string,
143 filter: TestFilter | null,

Callers 1

getFixturesFunction · 0.85

Calls 5

stripExtensionFunction · 0.85
joinMethod · 0.80
mapMethod · 0.65
pushMethod · 0.65
thenMethod · 0.65

Tested by

no test coverage detected