mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
c70aee247e
* refactor(scripts): migrate JavaScript tools to TypeScript * fix(ci): keep changed-scope preflight zero-install * fix(ci): preserve zero-install script owners * fix(ci): complete script migration follow-through * fix(release): keep stable closeout zero-install * fix(scripts): preserve standalone execution boundaries * fix(scripts): repair standalone loader boundaries * fix(scripts): normalize gateway observation ids * fix(scripts): keep Docker packager standalone * test(scripts): preserve rebase cleanup helpers * test(sessions): use tracked temp directory
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
// Lists tracked test files with a filesystem fallback for non-git contexts.
|
|
import { spawnSync } from "node:child_process";
|
|
import { existsSync, readdirSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
/** List git-tracked test files below a root, falling back to recursive filesystem discovery. */
|
|
export function listTrackedTestFiles(rootDir: string, suffix = ".test.ts"): string[] {
|
|
const result = spawnSync("git", ["ls-files", "--", rootDir], {
|
|
encoding: "utf8",
|
|
stdio: ["ignore", "pipe", "ignore"],
|
|
});
|
|
if (result.status === 0) {
|
|
return result.stdout
|
|
.split("\n")
|
|
.map((line) => line.trim().replaceAll("\\", "/"))
|
|
.filter((line) => line.endsWith(suffix))
|
|
.toSorted((a, b) => a.localeCompare(b));
|
|
}
|
|
|
|
if (!existsSync(rootDir)) {
|
|
return [];
|
|
}
|
|
|
|
const files: string[] = [];
|
|
const visit = (dir: string): void => {
|
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
const path = join(dir, entry.name);
|
|
if (entry.isDirectory()) {
|
|
visit(path);
|
|
continue;
|
|
}
|
|
if (entry.isFile() && entry.name.endsWith(suffix)) {
|
|
files.push(path.replaceAll("\\", "/"));
|
|
}
|
|
}
|
|
};
|
|
|
|
visit(rootDir);
|
|
return files.toSorted((a, b) => a.localeCompare(b));
|
|
}
|