MCPcopy
hub / github.com/PlasmoHQ/plasmo / resolveSourceIndex

Function resolveSourceIndex

core/parcel-resolver/src/shared.ts:96–115  ·  view source on GitHub ↗
(
  absoluteBaseFile: string,
  checkingExts = relevantExtensionList as readonly string[],
  opts = {} as Partial<ResolveResult>
)

Source from the content-addressed store, hash-verified

94 * Look for source code file (crawl index)
95 */
96export const resolveSourceIndex = async (
97 absoluteBaseFile: string,
98 checkingExts = relevantExtensionList as readonly string[],
99 opts = {} as Partial<ResolveResult>
100): Promise<ResolverResult> => {
101 const potentialFiles = checkingExts.flatMap((ext) => [
102 `${absoluteBaseFile}${ext}`,
103 resolve(absoluteBaseFile, `index${ext}`)
104 ])
105
106 for (const file of potentialFiles) {
107 try {
108 if (statSync(file).isFile()) {
109 return { filePath: file, ...opts }
110 }
111 } catch {}
112 }
113
114 return null
115}

Callers 3

handleTildeSrcFunction · 0.90
resolveByPrefixFunction · 0.90
handleAbsoluteRootFunction · 0.90

Calls 1

resolveFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…