MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / pickSourceIndex

Function pickSourceIndex

scripts/rehydrate-recovered-src.mjs:29–49  ·  view source on GitHub ↗
(map, relPath)

Source from the content-addressed store, hash-verified

27}
28
29function pickSourceIndex(map, relPath) {
30 if (!Array.isArray(map.sources) || !Array.isArray(map.sourcesContent)) {
31 return -1
32 }
33
34 const relBasename = path.posix.basename(relPath)
35
36 let index = map.sources.findIndex(source => {
37 if (typeof source !== 'string') return false
38 return source.replaceAll('\\', '/').endsWith(relPath)
39 })
40 if (index >= 0) return index
41
42 index = map.sources.findIndex(source => {
43 if (typeof source !== 'string') return false
44 return path.posix.basename(source.replaceAll('\\', '/')) === relBasename
45 })
46 if (index >= 0) return index
47
48 return map.sources.length === 1 ? 0 : -1
49}
50
51function applyCompatRewrites(sourceText) {
52 return sourceText

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected