export-pdf.sh silently discards the PDF when the output path is relative
Summary
scripts/export-pdf.sh never makes the output path absolute, then cds into its temp directory. When the second argument is a relative path, node writes the PDF inside the temp directory, which is removed on exit. The script prints ✓ PDF exported successfully! and leaves no file.
The script's own usage example is the failing case:
# bash scripts/export-pdf.sh ./presentation.html ./presentation.pdfMechanism
L85-88 # Resolve output to absolute path
OUTPUT_DIR=$(dirname "$OUTPUT_PDF") # dirname "./x.pdf" -> "." , still relative
mkdir -p "$OUTPUT_DIR"
OUTPUT_PDF="$OUTPUT_DIR/$(basename "$OUTPUT_PDF")"
L352 cd "$TEMP_DIR" # CWD moves
L389 node "$TEMP_SCRIPT" ... "$OUTPUT_PDF" ... # writes relative to TEMP_DIR
L397 rm -rf "$TEMP_DIR" # takes the PDF with itL76 does resolve INPUT_HTML correctly with cd ... && pwd; the output block is missing that step. Note this also means the no-second-argument path works fine, because L82 derives the output from the already-absolute INPUT_HTML. So the bug only shows when someone passes an explicit relative output path, which is exactly what the documented examples do.
The only surface symptom is the du: cannot access '<path>': No such file or directory line from the file-size step after the success banner.
Reproduction
bash scripts/export-pdf.sh /abs/path/deck.html ./out.pdf
# -> "✓ PDF exported successfully!" and no ./out.pdf anywhere on diskObserved on a 40-slide deck: all 40 slides captured, "Assembling PDF...", success banner, no file. The same deck with an absolute second argument produced a correct 3.5 MB PDF.
Fix
One line, after the mkdir -p:
OUTPUT_DIR=$(dirname "$OUTPUT_PDF")
mkdir -p "$OUTPUT_DIR"
OUTPUT_DIR=$(cd "$OUTPUT_DIR" && pwd) # <- add this
OUTPUT_PDF="$OUTPUT_DIR/$(basename "$OUTPUT_PDF")"Verified after the change: the same relative-path invocation writes a valid PDF at the requested path.
Environment
Linux (WSL2), bash 5.2, node v22. The logic is platform independent, so macOS should behave the same, but I only tested on Linux. Checked against main as of today; scripts/export-pdf.sh L85-88 unchanged.
Happy to open a PR if useful.
Source: zarazhangrui/frontend-slides