源码快照 @ 2026-09-02 (source-only, 剔除非源码素材)
This commit is contained in:
commit
04bac1f6e2
2200 files changed
+489415
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { rm } from "node:fs/promises";
|
||||
import { setTimeout } from "node:timers/promises";
|
||||
|
||||
const parentPid = Number.parseInt(process.argv[2] ?? "", 10);
|
||||
const rootPath = process.argv[3];
|
||||
|
||||
function parentIsRunning() {
|
||||
try {
|
||||
process.kill(parentPid, 0);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Number.isSafeInteger(parentPid) && parentPid > 0 && rootPath) {
|
||||
let attempts = 0;
|
||||
while (parentIsRunning() && attempts < 600) {
|
||||
attempts += 1;
|
||||
await setTimeout(100);
|
||||
}
|
||||
if (parentIsRunning()) process.exit(0);
|
||||
await rm(rootPath, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
maxRetries: 10,
|
||||
retryDelay: 200,
|
||||
}).catch(() => {
|
||||
process.exitCode = 1;
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user