mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:20:44 +00:00
fix(scripts): reap child check processes
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { performance } from "node:perf_hooks";
|
||||
import {
|
||||
detectChangedLanes,
|
||||
@@ -8,6 +7,7 @@ import {
|
||||
} from "./changed-lanes.mjs";
|
||||
import { booleanFlag, parseFlagArgs, stringFlag } from "./lib/arg-utils.mjs";
|
||||
import { printTimingSummary } from "./lib/check-timing-summary.mjs";
|
||||
import { runManagedCommand } from "./lib/managed-child-process.mjs";
|
||||
import { resolveChangedTestTargetPlan } from "./test-projects.test-support.mjs";
|
||||
|
||||
export function createChangedCheckPlan(result, options = {}) {
|
||||
@@ -216,31 +216,22 @@ async function runNode(command, timings) {
|
||||
async function runCommand(command, timings) {
|
||||
const startedAt = performance.now();
|
||||
console.error(`\n[check:changed] ${command.name}`);
|
||||
const child = spawn(command.bin, command.args, {
|
||||
stdio: "inherit",
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
let status = 1;
|
||||
try {
|
||||
status = await runManagedCommand({
|
||||
bin: command.bin,
|
||||
args: command.args,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
return await new Promise((resolve) => {
|
||||
child.once("error", (error) => {
|
||||
console.error(error);
|
||||
timings.push({
|
||||
name: command.name,
|
||||
durationMs: performance.now() - startedAt,
|
||||
status: 1,
|
||||
});
|
||||
resolve(1);
|
||||
});
|
||||
child.once("close", (status) => {
|
||||
const resolvedStatus = status ?? 1;
|
||||
timings.push({
|
||||
name: command.name,
|
||||
durationMs: performance.now() - startedAt,
|
||||
status: resolvedStatus,
|
||||
});
|
||||
resolve(resolvedStatus);
|
||||
});
|
||||
timings.push({
|
||||
name: command.name,
|
||||
durationMs: performance.now() - startedAt,
|
||||
status,
|
||||
});
|
||||
return status;
|
||||
}
|
||||
|
||||
function printSummary(timings, options) {
|
||||
|
||||
Reference in New Issue
Block a user