fix(shared): normalize macOS realpath output
This commit is contained in:
parent
a0c9381672
commit
74d2ae1023
@ -1,6 +1,10 @@
|
|||||||
import { lstatSync, realpathSync } from "fs"
|
import { lstatSync, realpathSync } from "fs"
|
||||||
import { promises as fs } 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 {
|
export function isMarkdownFile(entry: { name: string; isFile: () => boolean }): boolean {
|
||||||
return !entry.name.startsWith(".") && entry.name.endsWith(".md") && entry.isFile()
|
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 {
|
export function resolveSymlink(filePath: string): string {
|
||||||
try {
|
try {
|
||||||
return realpathSync(filePath)
|
return normalizeDarwinRealpath(realpathSync(filePath))
|
||||||
} catch {
|
} catch {
|
||||||
return filePath
|
return filePath
|
||||||
}
|
}
|
||||||
@ -23,7 +27,7 @@ export function resolveSymlink(filePath: string): string {
|
|||||||
|
|
||||||
export async function resolveSymlinkAsync(filePath: string): Promise<string> {
|
export async function resolveSymlinkAsync(filePath: string): Promise<string> {
|
||||||
try {
|
try {
|
||||||
return await fs.realpath(filePath)
|
return normalizeDarwinRealpath(await fs.realpath(filePath))
|
||||||
} catch {
|
} catch {
|
||||||
return filePath
|
return filePath
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user