MCPcopy Create free account
hub / github.com/TanStack/ai / runTransform

Function runTransform

codemods/move-sampling-to-model-options/transform.test.ts:17–42  ·  view source on GitHub ↗
(
  fixtureBaseName: string,
  ext: 'ts' | 'tsx',
)

Source from the content-addressed store, hash-verified

15}
16
17function runTransform(
18 fixtureBaseName: string,
19 ext: 'ts' | 'tsx',
20): { output: string; reports: Array<string> } {
21 const source = read(`${fixtureBaseName}.input.${ext}`)
22 const reports: Array<string> = []
23 const j = jscodeshift.withParser('tsx')
24 const result = transform(
25 { path: `${fixtureBaseName}.input.${ext}`, source },
26 {
27 jscodeshift: j,
28 j,
29 stats: () => {},
30 report: (msg: string) => {
31 reports.push(msg)
32 },
33 },
34 {},
35 )
36 if (typeof result !== 'string') {
37 throw new Error(
38 `transform returned ${typeof result} for ${fixtureBaseName}.input.${ext}; expected a string`,
39 )
40 }
41 return { output: result, reports }
42}
43
44// Run both sides through Prettier before comparing. recast (jscodeshift's
45// printer) emits semicolons and drops trailing commas, while the fixtures are

Callers 1

expectFixtureFunction · 0.70

Calls 3

readFunction · 0.70
transformFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected