Skip to content

Commit ed3ed1f

Browse files
committed
refactor: always patch
1 parent 7567567 commit ed3ed1f

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

test/prepare.mjs

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
import { existsSync } from "node:fs";
33
import { symlink } from "node:fs/promises";
4-
import { dirname, join, resolve } from "node:path";
4+
import { dirname, resolve } from "node:path";
55
import { fileURLToPath } from "node:url";
66
import { patch } from "ts-patch";
77
import { patch as patch1 } from "tsp1";
@@ -20,27 +20,17 @@ async function symlinkTsNode() {
2020
}
2121

2222
function patchTsModules() {
23-
/* ****************************************************************************************************************** *
24-
* Config
25-
* ****************************************************************************************************************** */
2623
const rootDir = __dirname;
27-
const tsDirs = ["typescript-three", "typescript-four-seven", "typescript"];
28-
/* ****************************************************************************************************************** *
29-
* Patch TS Modules
30-
* ****************************************************************************************************************** */
3124

32-
const baseDirs = new Map();
33-
34-
for (const tsDirName of tsDirs) {
35-
const mainDir = resolve(rootDir, "node_modules", tsDirName);
36-
if (!existsSync(join(mainDir, "lib-backup"))) baseDirs.set(tsDirName, mainDir);
25+
/** @param {string} moduleName */
26+
function patchTypescript(moduleName, tspatch) {
27+
const basedir = resolve(rootDir, "node_modules", moduleName);
28+
tspatch(["tsc.js", "typescript.js"], { basedir, dir: basedir });
3729
}
3830

39-
// Patch discovered modules
40-
for (const [dirName, dir] of baseDirs)
41-
if (dirName === "typescript-three") patch1(["tsc.js", "typescript.js"], { basedir: dir });
42-
else if (dirName === "typescript-four-seven") patch2(["tsc.js", "typescript.js"], { dir });
43-
else patch(["tsc.js", "typescript.js"], { dir });
31+
patchTypescript("typescript-three", patch1);
32+
patchTypescript("typescript-four-seven", patch2);
33+
patchTypescript("typescript", patch);
4434
}
4535

4636
patchTsModules();

0 commit comments

Comments
 (0)