(source, anchor)
| 10 | const buildSource = await readFile(buildScriptPath, 'utf8') |
| 11 | |
| 12 | function extractArrayBodyFromAnchor(source, anchor) { |
| 13 | const anchorIndex = source.indexOf(anchor) |
| 14 | if (anchorIndex === -1) throw new Error(`Unable to find anchor: ${anchor}`) |
| 15 | const bracketStart = source.indexOf('[', anchorIndex + anchor.length) |
| 16 | if (bracketStart === -1) throw new Error(`Unable to find array start for anchor: ${anchor}`) |
| 17 | let depth = 0 |
| 18 | for (let i = bracketStart; i < source.length; i += 1) { |
| 19 | const char = source[i] |
| 20 | if (char === '[') depth += 1 |
| 21 | if (char === ']') { |
| 22 | depth -= 1 |
| 23 | if (depth === 0) return source.slice(bracketStart + 1, i) |
| 24 | } |
| 25 | } |
| 26 | throw new Error(`Unable to parse array body for anchor: ${anchor}`) |
| 27 | } |
| 28 | |
| 29 | function parseBuildFeatures(source) { |
| 30 | return [...extractArrayBodyFromAnchor(source, 'const buildFeatures =').matchAll(/'([^']+)'/g)] |
no outgoing calls
no test coverage detected