mirror of
https://github.com/luckyyzh/pi-agent-integrated.git
synced 2026-10-03 11:09:34 +00:00
18 lines
358 B
TypeScript
18 lines
358 B
TypeScript
import fs from "fs";
|
|
|
|
type DirentType = Pick<fs.Dirent, "isDirectory" | "isFile">;
|
|
|
|
export function resolveDirentIsDirectory(
|
|
dirent: DirentType,
|
|
fullPath: string,
|
|
): boolean | null {
|
|
if (dirent.isDirectory()) return true;
|
|
if (dirent.isFile()) return false;
|
|
|
|
try {
|
|
return fs.statSync(fullPath).isDirectory();
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|