Repository navigation
Conversation
The writers that call `fs.writeFile` directly failed with ENOENT when the directory of `--output` did not exist, so `dist/slides.pptx` broke while one-piece PDF worked.
✅ Deploy Preview for slidev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@slidev/client
create-slidev
create-slidev-theme
@slidev/parser
@slidev/cli
@slidev/types
commit: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
exportSlidesnow creates the directory of--outputonce, before the browser starts, so every format can write into a path that does not exist yet.Why
Whether a missing output directory is an error depends on the format:
The writers disagree about whose job it is.
page.pdf({ path })creates the directory, since Playwright creates parent directories, andgenPagePngcallsfs.mkdir(..., { recursive: true }), which Markdown also goes through. Everything that callsfs.writeFiledirectly does not, which covers both PowerPoint formats and, less obviously,--format pdf --per-slide: that path renders each slide into a buffer, merges them and writes the result itself, so it never touches the Playwright call that would have created the directory.Tested on v53.0.0 against a deck with no
dist/folder:--format pdf--format pdf --per-slide--format png--format md--format pptx--format pptx-editabledist/is where most people put an export, and it is what the docs use in their examples, so this is easy to hit on a fresh checkout.Tests
packages/slidev/node/commands/export.test.tsis new, and it is the first test aroundexportSlides. A real export needs a browser and a dev server, but the test never gets that far.importPlaywrightasksgetRootsfor the user root, and that throws without an entry, so every call rejects before anything renders. The directory is created before that point, so the assertion still says whether the step ran. Each rejection is matched against that known failure, otherwise an error thrown by themkdiritself would satisfy the test instead of failing it. Four of the five cases fail without the one-line fix, and the file runs in milliseconds with no browser.Notes
The
fs.mkdircall sits beforechromium.launch, so an unwritable path fails straight away instead of after the whole deck has rendered. It does nothing when the directory already exists, or when--outputhas no directory part.For PNG,
--outputnames a directory rather than a file, so this creates its parent and the existingfs.mkdiringenPagePngstill creates the directory itself.A narrower fix would be to add the same call at each failing write site, in
genPagePdfPerSlide,genPagePptxandpackages/slidev/node/commands/pptx/index.ts. That leaves the shared path alone but keeps the difference between formats. I am happy to switch if you prefer it.pnpm lintpasses.vitest runreports the same 11 failures with and without this change, inapi-snapshots.test.tsandnode/syntax/integration.test.ts, so they look like snapshot drift onmain.