mirror of
https://github.com/sinanyuntu/trade-message-center.git
synced 2026-09-17 13:22:11 +08:00
32 lines
1015 B
JavaScript
32 lines
1015 B
JavaScript
// 清理 workspace 的所有生成产物
|
|
|
|
import { rmSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
|
const workspaceDir = resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
|
|
export const GENERATED_DIST_RELATIVE_PATHS = [
|
|
"apps/onetalk-contract/dist",
|
|
"apps/server/dist",
|
|
"apps/chrome-extension/dist",
|
|
];
|
|
|
|
export const cleanGeneratedDist = (rootDir = workspaceDir) => {
|
|
for (const relativePath of GENERATED_DIST_RELATIVE_PATHS) {
|
|
rmSync(resolve(rootDir, relativePath), { force: true, recursive: true });
|
|
}
|
|
};
|
|
|
|
const entryPath = process.argv[1];
|
|
const isMainModule = entryPath !== undefined && import.meta.url === pathToFileURL(entryPath).href;
|
|
|
|
/** 清理 workspace 包的 TypeScript 与 Vite 生成产物。 */
|
|
const run = () => {
|
|
cleanGeneratedDist();
|
|
console.info(
|
|
`[workspace] cleaned ${GENERATED_DIST_RELATIVE_PATHS.length} package dist directories`,
|
|
);
|
|
};
|
|
|
|
if (isMainModule) run();
|