Use inferred format extension for the output path (#2166)

This commit is contained in:
LU Jialin 2023-09-18 20:27:38 +08:00 committed by GitHub
parent 6378bb1754
commit 8b465222b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,9 +22,15 @@ type CodespanError = codespan_reporting::files::Error;
impl CompileCommand { impl CompileCommand {
/// The output path. /// The output path.
pub fn output(&self) -> PathBuf { pub fn output(&self) -> PathBuf {
self.output self.output.clone().unwrap_or_else(|| {
.clone() self.common.input.with_extension(
.unwrap_or_else(|| self.common.input.with_extension("pdf")) match self.output_format().unwrap_or(OutputFormat::Pdf) {
OutputFormat::Pdf => "pdf",
OutputFormat::Png => "png",
OutputFormat::Svg => "svg",
},
)
})
} }
/// The format to use for generated output, either specified by the user or inferred from the extension. /// The format to use for generated output, either specified by the user or inferred from the extension.