Skip to content

Commit 6a7571a

Browse files
committed
Update build script
1 parent f9033ee commit 6a7571a

File tree

4 files changed

+16
-153
lines changed

4 files changed

+16
-153
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dist"
2424
],
2525
"scripts": {
26-
"build": "rimraf dist && tsc -p tsconfig.build.json && babel dist/esm -d dist/cjs --out-file-extension .cjs && node script/after-build.js",
26+
"build": "node script/before-build.js && tsc -p tsconfig.build.json && babel dist/esm -d dist/cjs --out-file-extension .cjs && node script/after-build.js",
2727
"test": "vitest",
2828
"typecheck": "tsc",
2929
"lint": "eslint . && prettier . --check",
@@ -59,7 +59,6 @@
5959
"eslint-plugin-simple-import-sort": "^12.0.0",
6060
"globals": "^14.0.0",
6161
"prettier": "3.2.5",
62-
"rimraf": "^5.0.5",
6362
"temporal-polyfill": "^0.2.1",
6463
"typescript": "^5.3.3",
6564
"typescript-eslint": "^7.0.1",

pnpm-lock.yaml

-147
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

script/after-build.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-nocheck
2-
import { copyFile, readdir } from "node:fs/promises";
2+
import { copyFile, readdir, rm } from "node:fs/promises";
33
import path from "node:path";
44
import { fileURLToPath } from "node:url";
55

@@ -33,9 +33,14 @@ async function check(dirname, moduleName) {
3333
}
3434
}
3535
if (fail) {
36-
process.exit(1);
36+
throw new Error();
3737
}
3838
}
3939

40-
await check("datetime", "vremel");
41-
await check("duration", "vremel/duration");
40+
try {
41+
await check("datetime", "vremel");
42+
await check("duration", "vremel/duration");
43+
} catch {
44+
await rm(path.join(srcPath, "../dist"), { recursive: true, force: true });
45+
process.exit(1);
46+
}

script/before-build.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { rm } from "node:fs/promises";
2+
import path from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
5+
const rootPath = path.join(fileURLToPath(import.meta.url), "../..");
6+
await rm(path.join(rootPath, "dist"), { recursive: true, force: true });

0 commit comments

Comments
 (0)