Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions scripts/scaffold-screens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* --shared-model Emit src/common/model/SharedModel.ts; each screen model composes it
*/

import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { basename, dirname, join, relative, resolve } from "node:path";

// ── Argument parsing ──────────────────────────────────────────────────────────
Expand Down Expand Up @@ -234,11 +234,11 @@ function findPrototypeDir(): string {
return preferred;
}
// Legacy post-rename layout: {id}-screen/
for (const entry of readdirSync(SRC)) {
const full = join(SRC, entry);
if (!(statSync(full).isDirectory() && entry.endsWith("-screen"))) {
for (const entry of readdirSync(SRC, { withFileTypes: true })) {
if (!(entry.isDirectory() && entry.name.endsWith("-screen"))) {
continue;
}
const full = join(SRC, entry.name);
const screens = readdirSync(full).filter((f) => f.endsWith("Screen.ts") && !f.includes("View"));
if (screens.length === 1) {
return full;
Expand All @@ -250,11 +250,11 @@ function findPrototypeDir(): string {

function walkFiles(dir: string): string[] {
const out: string[] = [];
for (const entry of readdirSync(dir)) {
const full = join(dir, entry);
if (statSync(full).isDirectory()) {
for (const entry of readdirSync(dir, { withFileTypes: true })) {
const full = join(dir, entry.name);
if (entry.isDirectory()) {
out.push(...walkFiles(full));
} else {
} else if (entry.isFile()) {
out.push(full);
}
}
Expand Down Expand Up @@ -556,10 +556,12 @@ function updateDocs(screens: ScreenSpec[], simPrefix: string): void {
];

for (const path of paths) {
if (!existsSync(path)) {
let original: string;
try {
original = readFileSync(path, "utf8");
} catch {
continue;
}
const original = readFileSync(path, "utf8");
let text = original;
if (basename(path) === "multi-screen.md") {
for (const [from, to] of prose) {
Expand Down
3 changes: 1 addition & 2 deletions tests/memory-leak.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import { FIELD_VIEW_SIZE } from "../src/HeatTransferConstants.js";
* can exceed the Vitest testTimeout — always pass refs when you have them.
*/
async function forceGC(earlyExitRefs?: WeakRef<object> | readonly WeakRef<object>[]): Promise<void> {
const refs =
earlyExitRefs === undefined ? [] : Array.isArray(earlyExitRefs) ? earlyExitRefs : [earlyExitRefs];
const refs = earlyExitRefs === undefined ? [] : Array.isArray(earlyExitRefs) ? earlyExitRefs : [earlyExitRefs];
for (let i = 0; i < 15; i++) {
globalThis.gc?.();
await new Promise<void>((r) => setTimeout(r, 50));
Expand Down
Loading