MCPcopy
hub / github.com/marktext/marktext / normalizeAndResolvePath

Function normalizeAndResolvePath

packages/desktop/src/main/filesystem/index.ts:11–22  ·  view source on GitHub ↗
(pathname: string)

Source from the content-addressed store, hash-verified

9 * target cannot be resolved.
10 */
11export const normalizeAndResolvePath = (pathname: string): string => {
12 if (isSymbolicLink(pathname)) {
13 const absPath = path.dirname(pathname)
14 const targetPath = path.resolve(absPath, readlinkSync(pathname))
15 if (isFile(targetPath) || isDirectory(targetPath)) {
16 return path.resolve(targetPath)
17 }
18 console.error(`Cannot resolve link target "${pathname}" (${targetPath}).`)
19 return ''
20 }
21 return path.resolve(pathname)
22}
23
24export const writeFile = (
25 pathname: string,

Callers 4

file.tsFile · 0.90
openFileOrFolderFunction · 0.90
_listenForIpcMainMethod · 0.90
normalizeMarkdownPathFunction · 0.90

Calls 5

isSymbolicLinkFunction · 0.90
isFileFunction · 0.90
isDirectoryFunction · 0.90
dirnameMethod · 0.80
resolveMethod · 0.80

Tested by

no test coverage detected