Skip to content

Commit f9a4d98

Browse files
Convert package-fixup script to typescript
1 parent db62a69 commit f9a4d98

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"review": "elm-review --fix",
2323
"review:ci": "elm-review",
2424
"review:watch": "elm-review --watch",
25-
"runner:compile": "rm -rf lib/* && tsc -p tsconfig-mjs.json && tsc -p tsconfig-cjs.json && ./scripts/package-fixup.sh",
25+
"runner:sub-package-json": "node --experimental-strip-types ./scripts/package-fixup.mts",
26+
"runner:compile": "rm -rf lib/* && tsc -p tsconfig-mjs.json && tsc -p tsconfig-cjs.json && npm run runner:sub-package-json",
2627
"check-versions": "node --experimental-strip-types ./scripts/versions.mts"
2728
},
2829
"author": "Andrew MacMurray",

scripts/package-fixup.mts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import fs from "node:fs/promises";
2+
3+
// Adds package.json files to cjs/mjs subtrees
4+
5+
const writePackageJson = (path: string, contents: Record<string, string>) => {
6+
return fs.writeFile(`${path}/package.json`, JSON.stringify(contents, null, 2));
7+
};
8+
9+
Promise.all([
10+
writePackageJson("lib/cjs", { type: "commonjs" }),
11+
writePackageJson("lib/mjs", { type: "module" }),
12+
]).then(() => {
13+
console.log("Wrote sub package JSONs for compiled runners ✅");
14+
});

scripts/package-fixup.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)