|
6 | 6 | import { describe, it, expect, beforeEach, vi } from "vitest"; |
7 | 7 | import { readFileSync, readdirSync } from "fs"; |
8 | 8 | import { mkdtemp, rm, writeFile } from "fs/promises"; |
9 | | -import { tmpdir } from "os"; |
10 | 9 | import { resolve } from "path"; |
11 | 10 | import { Readable, Writable } from "stream"; |
12 | 11 | import { execFile } from "child_process"; |
@@ -282,21 +281,32 @@ describe("skill markdown samples", () => { |
282 | 281 |
|
283 | 282 | describe("skill markdown samples typecheck", () => { |
284 | 283 | it("typechecks extracted rig programs with npx tsc", async () => { |
285 | | - const typecheckDir = await mkdtemp(resolve(tmpdir(), "rig-sample-typecheck-")); |
| 284 | + const typecheckDir = await mkdtemp(resolve(__dirname, ".tmp-rig-sample-typecheck-")); |
286 | 285 | try { |
287 | 286 | for (const file of markdownTargets) { |
288 | 287 | const markdown = readFileSync(resolve(markdownDir, file), "utf8"); |
289 | 288 | const code = withTypecheckModel(extractRigCode(markdown)); |
290 | 289 | const tsFile = resolve(typecheckDir, file.replace(/\.md$/, ".ts")); |
291 | 290 | await writeFile(tsFile, `${code}\n`, "utf8"); |
292 | 291 | } |
| 292 | + const tsconfigPath = resolve(typecheckDir, "tsconfig.json"); |
| 293 | + await writeFile( |
| 294 | + tsconfigPath, |
| 295 | + JSON.stringify( |
| 296 | + { |
| 297 | + extends: "../../tsconfig.json", |
| 298 | + include: ["./*.ts"], |
| 299 | + }, |
| 300 | + null, |
| 301 | + 2, |
| 302 | + ), |
| 303 | + ); |
293 | 304 |
|
294 | 305 | await execFileAsync( |
295 | 306 | "npx", |
296 | | - ["--yes", "--package", "typescript@5.9.3", "--", "tsc", "--noEmit", "--pretty", "false"], |
| 307 | + ["tsc", "--project", tsconfigPath, "--pretty", "false"], |
297 | 308 | { |
298 | 309 | cwd: resolve(__dirname, ".."), |
299 | | - env: { ...process.env, npm_config_ignore_scripts: "true" }, |
300 | 310 | }, |
301 | 311 | ); |
302 | 312 | } finally { |
|
0 commit comments