Skip to content

feat: expose getPandocPath/getMutoolPath to reuse resolved binary paths - #266

Merged
Kikobeats merged 3 commits into
masterfrom
expose-pandoc-path
Jul 2, 2026
Merged

feat: expose getPandocPath/getMutoolPath to reuse resolved binary paths#266
Kikobeats merged 3 commits into
masterfrom
expose-pandoc-path

Conversation

@Kikobeats

@Kikobeats Kikobeats commented Jul 2, 2026

Copy link
Copy Markdown
Member

What

html-get already resolves pandoc (office→HTML) and mutool (PDF→HTML) internally. This makes html-get the single owner of that binary resolution and exposes the resolved paths so a consumer can reuse them instead of running its own which.

  • Cache the which <bin> lookup per binary (whichCache Map), so the internal runners (defaultMutool/defaultPandoc) and the new accessors share one resolution per process. Absent binaries are cached as undefined too, so a missing tool isn't re-probed.
  • Export getPandocPath() and getMutoolPath() — each returns the cached path, or undefined when the binary is not installed. Lazy: nothing runs until first call.

Why

The microlink api runs its own execFileSync('which', ['pandoc']) in the markdown pipeline, and passes a mutoolPath that html-get never read. With this, the api reuses require('html-get').getPandocPath() and drops both redundant which calls (separate api PR, gated on this release). getMutoolPath() is exposed for parity/future use.

Tests

  • getPandocPath/getMutoolPath exposes the resolved <bin> path (parameterized, asserts each matches which <bin>, tolerates an absent binary)
  • existing office/probe suite unchanged: 28/28 test/office.js pass, lint clean

Notes

  • memoizeOne on the runners stays: whichCache only dedupes the which lookup, while memoizeOne also avoids re-running the pandoc --list-input-formats probe and rebuilding the runner closure per request.

🤖 Generated with Claude Code

Kikobeats and others added 3 commits July 2, 2026 11:30
html-get owns the pandoc/mutool `which` lookup: cache it per binary so the
internal runners and consumers share a single resolution per process. Expose
getPandocPath() so an app (microlink api) reuses the resolved path for its own
pandoc pipeline instead of running `which pandoc` again.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fold the two near-identical accessor tests into one loop with consistent
error handling, removing the copy-pasted which resolution.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Kikobeats Kikobeats changed the title feat: expose getPandocPath to reuse the resolved pandoc binary feat: expose getPandocPath/getMutoolPath to reuse resolved binary paths Jul 2, 2026
@Kikobeats
Kikobeats merged commit f459ce1 into master Jul 2, 2026
3 checks passed
@Kikobeats
Kikobeats deleted the expose-pandoc-path branch July 2, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant