Fix: index.htmlでロゴのパスが誤っている問題を修正 / New: ディレクトリを探す関数
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user