-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06fb210
commit dca88cc
Showing
3 changed files
with
23 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 10 additions & 5 deletions
15
packages/tasks/scripts/generate-cts.ts → packages/tasks/scripts/rename-cts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
// Just copy over the already generated .d.ts and .d.ts.map files to .d.cts and .d.cts.map files | ||
import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs"; | ||
import { readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs"; | ||
import { join } from "node:path"; | ||
|
||
function recursiveCopy(path: string) { | ||
function recursiveRename(path: string) { | ||
for (const item of readdirSync(path)) { | ||
if (item.endsWith(".d.ts")) { | ||
const content = readFileSync(join(path, item), "utf-8"); | ||
writeFileSync(join(path, item.replace(".d.ts", ".d.cts")), content.replaceAll(".d.ts.map", ".d.cts.map")); | ||
rmSync(join(path, item)); | ||
} else if (item.endsWith(".d.ts.map")) { | ||
const content = readFileSync(join(path, item), "utf-8"); | ||
writeFileSync(join(path, item.replace(".d.ts.map", ".d.cts.map")), content.replaceAll(".d.ts", ".d.cts")); | ||
} else if (statSync(join(path, item)).isDirectory()) { | ||
recursiveCopy(join(path, item)); | ||
rmSync(join(path, item)); | ||
} /* else if (item.endsWith(".js")) { | ||
const content = readFileSync(join(path, item), "utf-8"); | ||
writeFileSync(join(path, item.replace(".js", ".cjs")), content); | ||
} */ else if (statSync(join(path, item)).isDirectory()) { | ||
recursiveRename(join(path, item)); | ||
} | ||
} | ||
} | ||
|
||
recursiveCopy("dist"); | ||
recursiveRename("dist/cjs"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { readFileSync, writeFileSync } from "fs"; | ||
|
||
const arg = process.argv[2]; | ||
|
||
const file = readFileSync("package.json", "utf-8"); | ||
|
||
writeFileSync("package.json", file.replace(/"type": ".*"/, `"type": "${arg}"`)); |