Skip to content

Commit

Permalink
Fix reading aux dir and out dir from latexmk (#971)
Browse files Browse the repository at this point in the history
`latexmk` writes the output to stderr and not stdout. Also, don't panic if the output is invalid and return an error instead.
  • Loading branch information
pfoerster authored Dec 2, 2023
1 parent 4aabfa1 commit b11a150
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/parser/src/latexmkrc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ pub fn parse_latexmkrc(_input: &str) -> std::io::Result<LatexmkrcData> {
.arg(non_existent_tex)
.output()?;

let stdout = String::from_utf8_lossy(&output.stdout);

let (aux_dir, out_dir) = stdout
.lines()
.filter_map(extract_dirs)
.next()
.expect("Normalized aux and out dir were not found in latexmk output");
let stderr = String::from_utf8_lossy(&output.stderr);

let (aux_dir, out_dir) = stderr.lines().find_map(extract_dirs).ok_or_else(|| {
std::io::Error::new(
std::io::ErrorKind::InvalidData,
"Normalized aux and out dir were not found in latexmk output",
)
})?;

Ok(LatexmkrcData {
aux_dir: Some(aux_dir),
Expand Down

0 comments on commit b11a150

Please sign in to comment.