





























@@ -1,14 +1,10 @@
11import { spawn } from "node:child_process";
22import fs from "node:fs";
3-import { createRequire } from "node:module";
43import path, { resolve } from "node:path";
4+import { isLocalCheckEnabled } from "./lib/local-heavy-check-runtime.mjs";
556-const require = createRequire(import.meta.url);
76const repoRoot = resolve(import.meta.dirname, "..");
8-const tsgoBin = path.join(
9-path.dirname(require.resolve("@typescript/native-preview/package.json")),
10-"bin/tsgo.js",
11-);
7+const runTsgoScript = path.join(repoRoot, "scripts/run-tsgo.mjs");
128const TYPE_INPUT_EXTENSIONS = new Set([".ts", ".tsx", ".d.ts", ".js", ".mjs", ".json"]);
139const VALID_MODES = new Set(["all", "package-boundary"]);
1410@@ -167,7 +163,7 @@ export function runNodeStep(label, args, timeoutMs, params = {}) {
167163return new Promise((resolvePromise, rejectPromise) => {
168164const child = spawn(process.execPath, args, {
169165cwd: repoRoot,
170-env: process.env,
166+env: params.env ? { ...process.env, ...params.env } : process.env,
171167signal: abortController?.signal,
172168stdio: ["ignore", "pipe", "pipe"],
173169});
@@ -231,14 +227,27 @@ export function runNodeStep(label, args, timeoutMs, params = {}) {
231227export async function runNodeStepsInParallel(steps) {
232228const abortController = new AbortController();
233229const results = await Promise.allSettled(
234-steps.map((step) => runNodeStep(step.label, step.args, step.timeoutMs, { abortController })),
230+steps.map((step) =>
231+runNodeStep(step.label, step.args, step.timeoutMs, { abortController, env: step.env }),
232+),
235233);
236234const firstFailure = results.find((result) => result.status === "rejected");
237235if (firstFailure) {
238236throw firstFailure.reason;
239237}
240238}
241239240+export async function runNodeSteps(steps, env = process.env) {
241+if (!isLocalCheckEnabled(env)) {
242+await runNodeStepsInParallel(steps);
243+return;
244+}
245+246+for (const step of steps) {
247+await runNodeStep(step.label, step.args, step.timeoutMs, { env: step.env });
248+}
249+}
250+242251export async function main(argv = process.argv.slice(2)) {
243252try {
244253const mode = parseMode(argv);
@@ -272,7 +281,8 @@ export async function main(argv = process.argv.slice(2)) {
272281});
273282pendingSteps.push({
274283label: "plugin-sdk boundary dts",
275-args: [tsgoBin, "-p", "tsconfig.plugin-sdk.dts.json"],
284+args: [runTsgoScript, "-p", "tsconfig.plugin-sdk.dts.json", "--declaration", "true"],
285+env: { OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD: "1" },
276286timeoutMs: 300_000,
277287stampPath: ROOT_DTS_STAMP,
278288});
@@ -287,7 +297,8 @@ export async function main(argv = process.argv.slice(2)) {
287297});
288298pendingSteps.push({
289299label: "plugin-sdk package boundary dts",
290-args: [tsgoBin, "-p", "packages/plugin-sdk/tsconfig.json"],
300+args: [runTsgoScript, "-p", "packages/plugin-sdk/tsconfig.json", "--declaration", "true"],
301+env: { OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD: "1" },
291302timeoutMs: 300_000,
292303stampPath: PACKAGE_DTS_STAMP,
293304});
@@ -296,7 +307,7 @@ export async function main(argv = process.argv.slice(2)) {
296307}
297308298309if (pendingSteps.length > 0) {
299-await runNodeStepsInParallel(pendingSteps);
310+await runNodeSteps(pendingSteps);
300311for (const step of pendingSteps) {
301312if (step.stampPath) {
302313writeStampFile(step.stampPath);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。