diff --git a/script/extract-source-links.ts b/script/extract-source-links.ts index 6aa3acc59e..25e78ddad4 100755 --- a/script/extract-source-links.ts +++ b/script/extract-source-links.ts @@ -98,12 +98,18 @@ function shouldSkipFile(filepath: string): boolean { if (/\.test\.[jt]sx?$/.test(filepath)) return true if (/\.spec\.[jt]sx?$/.test(filepath)) return true if (/\.stories\.[jt]sx?$/.test(filepath)) return true - if (/\/i18n\//.test(filepath) && !filepath.endsWith("en.ts")) return true + if (parts.includes("i18n") && path.basename(filepath) !== "en.ts") return true // kilocode_change const basename = path.basename(filepath) if (SKIP_FILES.includes(basename)) return true return false } +// kilocode_change start +function source(filepath: string): string { + return path.relative(ROOT, filepath).replaceAll(path.sep, "/") +} +// kilocode_change end + function clean(url: string): string { return url.replace(/[.),:;]+$/, "").replace(/<\/?\w+>$/, "") } @@ -115,16 +121,19 @@ async function extract(): Promise>> { for (const ext of EXTENSIONS) { const glob = new Glob(`**/*.${ext}`) for await (const entry of glob.scan({ cwd: dir, absolute: true })) { - if (shouldSkipFile(entry)) continue + // kilocode_change start + const file = source(entry) + if (shouldSkipFile(file)) continue const content = await Bun.file(entry).text() for (const line of content.split("\n")) { for (const match of line.matchAll(URL_RE)) { const url = clean(match[0]) if (shouldExclude(url)) continue if (!links.has(url)) links.set(url, new Set()) - links.get(url)!.add(path.relative(ROOT, entry)) + links.get(url)!.add(file) } } + // kilocode_change end } } }