fix(generate-pdf): silent no-op on Windows - build file:// URLs with pathToFileURL#949
fix(generate-pdf): silent no-op on Windows - build file:// URLs with pathToFileURL#949shuhia wants to merge 1 commit into
Conversation
The main-module guard compared import.meta.url against a hand-built
`file://${resolve(process.argv[1])}` string. On Windows, resolve()
returns backslash paths (C:\... or \\wsl.localhost\... UNC), so the
comparison never matched: the CLI entry point never ran and the script
exited 0 silently without generating anything.
Use pathToFileURL() like the other CLI scripts already do (scan.mjs,
scan-ats-full.mjs, update-system.mjs, followup-cadence.mjs), and fix
the two other hand-built file:// URLs in the same file (fonts
injection and the Playwright baseURL), which produced invalid
backslash URLs on Windows.
Fixes santifer#948
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR fixes URL handling in ChangesCross-platform URL path handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 #948
What
On Windows,
node generate-pdf.mjs <input.html> <output.pdf>was a silent no-op: no output, no PDF, exit code 0. The main-module guard hand-built the comparison URL:On Windows
resolve()returns backslash paths (C:\..., or\\wsl.localhost\...UNC when the repo lives in WSL), so the string never equalsimport.meta.url(file:///C:/...forward-slash form).isMainstayedfalse, the CLI entry never ran, and the script exited 0 after merely being imported.This PR replaces the hand-built string with
pathToFileURL()— the same pattern the repo already uses inscan.mjs,scan-ats-full.mjs,update-system.mjs, andfollowup-cadence.mjs.generate-pdf.mjswas the last script with the hand-built guard.Per the issue, I grepped for all remaining
`file://${...}`interpolations and fixed the other two in the same file, which produced invalid backslash URLs on Windows:url('file://${fontsDir}/) → broken font loading, wrong typography in the PDFbaseURL(file://${baseDir}/) → broken relative resources4 lines changed (3 sites + the
pathToFileURLimport). No behavior change on Linux/macOS: for POSIX absolute pathspathToFileURL().hrefproduces the samefile:///...string the template literal did (and additionally percent-encodes special characters correctly).Verification (Windows 11, Node v24.14.0)
Before (clean clone of
main@ 0d57994):After:
End-to-end render on Windows with
templates/cv-template.html(exercises the fonts rewrite + baseURL):Test suite (
node test-all.mjs): 240 passed, 3 failed — and the identical 3 failures occur on unmodifiedmainon this machine, all Windows-environment issues unrelated to this change (Go toolchain missing for the dashboard build,.claude/.../SKILL.mdsymlink checked out as a plain file,spawnSync chmod ENOENT). Linux CI should be fully green.🤖 Generated with Claude Code
Summary by CodeRabbit