fix(scripts): make the docs link check work on Windows - #11181
Conversation
'relativeLinkExists' builds the target path with 'path.resolve', which uses the platform separator, but then matches it against '/examples/' and rewrites it with a regex written in forward slashes. On Windows the resolved path uses backslashes, so neither pattern matches. Every documentation link that points at an example is looked up as a markdown file under 'docs/framework/<name>/examples/' instead of a directory under 'examples/<name>/', and 'pnpm test:docs' reports 27 broken links that are fine on CI. Normalize the separators before the two comparisons. Node accepts forward slashes on Windows, so the resolved path stays usable.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe link verification script now normalizes platform-specific path separators before detecting and transforming example paths. ChangesLink verification
Estimated code review effort: 1 (Trivial) | ~5 minutes Mergeability Score: ⚪ Minimal · up to This localized documentation-link checker fix changes path normalization for Windows without introducing a merge-blocking risk; it is merge-ready after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #11177
The problem
relativeLinkExistsbuilds the target path withpath.resolve, which uses the platform separator, and then matches that path against patterns written with forward slashes:On Windows the resolved path uses backslashes, so neither pattern matches. Every documentation link pointing at an example skips the rewrite and gets looked up as a markdown file under
docs/framework/<name>/examples/instead of a directory underexamples/<name>/.pnpm test:docsthen reports 27 broken links that are all fine. CI does not catch it because it runs on Linux, and the reportedresolved:path shows the problem directly.The change
Normalize the separators once, before the two comparisons. Node accepts forward slashes on Windows, so the path stays usable for
existsSyncandstatSync, and the value printed in the error report stays readable.The
docsRootcontainment check above it still runs on the platform native path, so it is unaffected.Tests
node scripts/verify-links.tson Windows goes from 27 reported broken links to "No broken links found". Behaviour on Linux is unchanged, sincesplit(sep).join('/')is a no-op there.No changeset, this is repository tooling.
Summary by CodeRabbit