more functional design principles
Some checks failed
ci/woodpecker/pr/pr Pipeline failed

This commit is contained in:
Madison Grubb
2026-02-17 11:17:52 -05:00
parent 1a566e2d80
commit c8d37c98f4
14 changed files with 357 additions and 321 deletions

View File

@@ -28,12 +28,23 @@ function getRelativeImports(content) {
const paths = []
const fromRegex = /from\s+['"]([^'"]+)['"]/g
const requireRegex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g
for (const re of [fromRegex, requireRegex]) {
let m
while ((m = re.exec(content)) !== null) {
const p = m[1]
if (p.startsWith('.')) paths.push(p)
const extractMatches = (regex, text) => {
const matches = []
const execRegex = (r) => {
const match = r.exec(text)
if (match) {
matches.push(match[1])
return execRegex(r)
}
return matches
}
return execRegex(regex)
}
for (const re of [fromRegex, requireRegex]) {
const matches = extractMatches(re, content)
matches.forEach((p) => {
if (p.startsWith('.')) paths.push(p)
})
}
return paths
}