MCPcopy
hub / github.com/vitejs/vite / tryResolveRealFileOrType

Function tryResolveRealFileOrType

packages/vite/src/node/plugins/resolve.ts:1164–1176  ·  view source on GitHub ↗
(
  file: string,
  preserveSymlinks?: boolean,
)

Source from the content-addressed store, hash-verified

1162}
1163
1164function tryResolveRealFileOrType(
1165 file: string,
1166 preserveSymlinks?: boolean,
1167): { path?: string; type: 'directory' | 'file' } | undefined {
1168 const fileStat = tryStatSync(file)
1169 if (fileStat?.isFile()) {
1170 return { path: getRealPath(file, preserveSymlinks), type: 'file' }
1171 }
1172 if (fileStat?.isDirectory()) {
1173 return { type: 'directory' }
1174 }
1175 return
1176}
1177
1178function getRealPath(resolved: string, preserveSymlinks?: boolean): string {
1179 if (!preserveSymlinks) {

Callers 1

tryCleanFsResolveFunction · 0.85

Calls 2

tryStatSyncFunction · 0.90
getRealPathFunction · 0.85

Tested by

no test coverage detected