fix(shared): normalize macOS realpath output

This commit is contained in:
YeonGyu-Kim 2026-02-14 22:06:13 +09:00
parent a0c9381672
commit 74d2ae1023

View File

@ -1,6 +1,10 @@
import { lstatSync, realpathSync } from "fs"
import { promises as fs } from "fs"
function normalizeDarwinRealpath(filePath: string): string {
return filePath.startsWith("/private/var/") ? filePath.slice("/private".length) : filePath
}
export function isMarkdownFile(entry: { name: string; isFile: () => boolean }): boolean {
return !entry.name.startsWith(".") && entry.name.endsWith(".md") && entry.isFile()
}
@ -15,7 +19,7 @@ export function isSymbolicLink(filePath: string): boolean {
export function resolveSymlink(filePath: string): string {
try {
return realpathSync(filePath)
return normalizeDarwinRealpath(realpathSync(filePath))
} catch {
return filePath
}
@ -23,7 +27,7 @@ export function resolveSymlink(filePath: string): string {
export async function resolveSymlinkAsync(filePath: string): Promise<string> {
try {
return await fs.realpath(filePath)
return normalizeDarwinRealpath(await fs.realpath(filePath))
} catch {
return filePath
}