|
1 | 1 | // Just copy over the already generated .d.ts and .d.ts.map files to .d.cts and .d.cts.map files |
2 | | -import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs"; |
| 2 | +import { readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs"; |
3 | 3 | import { join } from "node:path"; |
4 | 4 |
|
5 | | -function recursiveCopy(path: string) { |
| 5 | +function recursiveRename(path: string) { |
6 | 6 | for (const item of readdirSync(path)) { |
7 | 7 | if (item.endsWith(".d.ts")) { |
8 | 8 | const content = readFileSync(join(path, item), "utf-8"); |
9 | 9 | writeFileSync(join(path, item.replace(".d.ts", ".d.cts")), content.replaceAll(".d.ts.map", ".d.cts.map")); |
| 10 | + rmSync(join(path, item)); |
10 | 11 | } else if (item.endsWith(".d.ts.map")) { |
11 | 12 | const content = readFileSync(join(path, item), "utf-8"); |
12 | 13 | writeFileSync(join(path, item.replace(".d.ts.map", ".d.cts.map")), content.replaceAll(".d.ts", ".d.cts")); |
13 | | - } else if (statSync(join(path, item)).isDirectory()) { |
14 | | - recursiveCopy(join(path, item)); |
| 14 | + rmSync(join(path, item)); |
| 15 | + } /* else if (item.endsWith(".js")) { |
| 16 | + const content = readFileSync(join(path, item), "utf-8"); |
| 17 | + writeFileSync(join(path, item.replace(".js", ".cjs")), content); |
| 18 | + } */ else if (statSync(join(path, item)).isDirectory()) { |
| 19 | + recursiveRename(join(path, item)); |
15 | 20 | } |
16 | 21 | } |
17 | 22 | } |
18 | 23 |
|
19 | | -recursiveCopy("dist"); |
| 24 | +recursiveRename("dist/cjs"); |
0 commit comments