From c4f5ba84d184011dc9d238ce13abefd52eaa99c4 Mon Sep 17 00:00:00 2001 From: Jon Heinritz Date: Fri, 20 Jun 2025 08:30:39 +0200 Subject: [PATCH] feat(cli): also create output directory if it doesn't already exist --- crates/typst-cli/src/compile.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/typst-cli/src/compile.rs b/crates/typst-cli/src/compile.rs index 86e39f484..afc6863d0 100644 --- a/crates/typst-cli/src/compile.rs +++ b/crates/typst-cli/src/compile.rs @@ -137,6 +137,14 @@ impl CompileConfig { panic!("input path must be non-empty, as guarded by the CLI"); }; + // create directory if doesn't exist yet + std::fs::create_dir_all(&path).map_err(|err| { + eco_format!( + "failed to create output directory at {path}: {err}", + path = path.display() + ) + })?; + path.push(file_name); path.set_extension(match output_format { OutputFormat::Pdf => "pdf",