Fix: index.htmlでロゴのパスが誤っている問題を修正 / New: ディレクトリを探す関数

This commit is contained in:
2026-03-21 12:05:59 +09:00
parent fa7a1e87ff
commit b61e1206fc
2 changed files with 27 additions and 2 deletions
+25
View File
@@ -0,0 +1,25 @@
import { existsSync } from "node:fs";
import { dirname, join } from "node:path";
export function findDir(
targetPath: string,
cwd: string,
): string {
let current = cwd;
while (true) {
const candidate = join(current, targetPath);
if (existsSync(candidate)) {
return candidate;
}
const parent = dirname(current);
if (parent === current) {
throw new Error(`Not found: ${targetPath}`);
}
current = parent;
}
}