chore(release): satisfy parallel runner lint

This commit is contained in:
Vincent Koc
2026-07-10 15:56:36 -07:00
committed by Vincent Koc
parent e7cb09a2c2
commit 7f9ea2f7b4
3 changed files with 22 additions and 14 deletions
+10 -5
View File
@@ -1323,7 +1323,7 @@ function updateOrCheckPackage(packageDir, check, changedPaths = []) {
}
export async function runBoundedTasks(items, jobs, runTask) {
const results = new Array(items.length);
const results = Array.from({ length: items.length });
let nextIndex = 0;
const workers = Array.from({ length: Math.min(jobs, items.length) }, async () => {
while (nextIndex < items.length) {
@@ -1427,15 +1427,20 @@ if (!isMainThread && workerData?.kind === SHRINKWRAP_WORKER_KIND) {
workerData.check,
workerData.changedPaths,
);
// oxlint-disable-next-line unicorn/require-post-message-target-origin -- Node MessagePort has no targetOrigin parameter.
parentPort?.postMessage({ output });
} catch (error) {
// oxlint-disable-next-line unicorn/require-post-message-target-origin -- Node MessagePort has no targetOrigin parameter.
parentPort?.postMessage({ error: error instanceof Error ? error.message : String(error) });
}
} else if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
main().catch((error) => {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
});
main().catch(handleMainError);
}
/** @param {unknown} error */
function handleMainError(error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
export {
+9 -8
View File
@@ -126,17 +126,17 @@ if (shouldCheckMacosVersions) {
console.log("[release-preflight] macOS app version metadata OK");
}
}
const { failed } = await runTaskGraph({
const { failed: checkFailures } = await runTaskGraph({
commandKey: "check",
jobs: parsedArgs.jobs,
tasks: selectedTasks,
});
if (macosVersionErrors.length !== 0 || failed.length !== 0) {
if (macosVersionErrors.length !== 0 || checkFailures.length !== 0) {
console.error("\nrelease preflight found drift:");
for (const error of macosVersionErrors) {
console.error(`- macOS app version metadata: ${error}`);
}
printCommandFailures(failed);
printCommandFailures(checkFailures);
console.error(
"\nCorrect manual version metadata first. Run `pnpm release:prep` for intentional generated version/config/API changes, then commit the resulting files.",
);
@@ -220,7 +220,8 @@ async function runTaskGraph({ commandKey, jobs, tasks }) {
const runnableTasks = tasks
.filter((task) => task[commandKey])
.map((task) => ({
...task,
id: task.id,
name: task.name,
args: task[commandKey],
after: commandKey === "fix" ? (task.fixAfter ?? []) : [],
}));
@@ -228,7 +229,7 @@ async function runTaskGraph({ commandKey, jobs, tasks }) {
const pending = new Map(runnableTasks.map((task) => [task.id, task]));
const completed = new Set();
const failedIds = new Set();
const failed = [];
const taskFailures = [];
const skipped = [];
while (pending.size > 0) {
@@ -267,13 +268,13 @@ async function runTaskGraph({ commandKey, jobs, tasks }) {
completed.add(task.id);
} else {
failedIds.add(task.id);
failed.push({ ...task, status });
taskFailures.push({ ...task, status });
}
}
}
}
return { failed, skipped };
return { failed: taskFailures, skipped };
}
async function runCommand(command) {
@@ -407,5 +408,5 @@ function taskMatchesScopes(task, scopes) {
}
function formatScopes(scopes) {
return [...scopes].toSorted().join(",");
return [...scopes].toSorted((left, right) => left.localeCompare(right)).join(",");
}
+3 -1
View File
@@ -97,7 +97,9 @@ describe("generate-npm-shrinkwrap", () => {
const results = await runBoundedTasks(["slow", "fast", "last"], 2, async (value) => {
active += 1;
maxActive = Math.max(maxActive, active);
await new Promise((resolve) => setTimeout(resolve, value === "slow" ? 30 : 5));
await new Promise<void>((resolve) => {
setTimeout(resolve, value === "slow" ? 30 : 5);
});
active -= 1;
return value;
});