Copy the fixture, apply the variant, index it. Hermetic per run.
(variant)
| 85 | |
| 86 | /** Copy the fixture, apply the variant, index it. Hermetic per run. */ |
| 87 | function materialize(variant) { |
| 88 | const dir = mkdtempSync(join(tmpdir(), 'cg-decl-')); |
| 89 | cpSync(FIXTURE, dir, { recursive: true }); |
| 90 | rmSync(join(dir, '.codegraph'), { recursive: true, force: true }); |
| 91 | if (variant === 'strip-banner') { |
| 92 | const p = join(dir, GENERATED_DECL); |
| 93 | // Drop only the banner comment lines; every declaration stays. |
| 94 | const kept = readFileSync(p, 'utf8').split('\n').filter((l) => !/^\/\/ .*(Generated by Wrangler|Runtime types generated)/.test(l)); |
| 95 | writeFileSync(p, kept.join('\n')); |
| 96 | } else if (variant !== 'both') { |
| 97 | rmSync(dir, { recursive: true, force: true }); |
| 98 | throw new Error(`unknown --variant ${variant} (both | strip-banner)`); |
| 99 | } |
| 100 | return dir; |
| 101 | } |
| 102 | |
| 103 | const queries = ONE_QUERY |
| 104 | ? [{ id: 'custom', kind: 'flow', text: ONE_QUERY }] |