mirror of https://github.com/aya-rs/aya
aya-tool: do not attempt to run rustfmt
This can be done externally. Do so in CI. This is an attempt to resolve the inconsistency between CI and local rustfmt in the generated bindings. Restore running CI on generated branches; the presence of a PR is apparently not enough.reviewable/pr1202/r1
parent
2bb2302d1d
commit
c42f9f507e
@ -1,26 +0,0 @@
|
|||||||
use std::{
|
|
||||||
io::{self, Write},
|
|
||||||
process::{Command, Output, Stdio},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn format(code: &str) -> Result<String, io::Error> {
|
|
||||||
let mut child = Command::new("rustfmt")
|
|
||||||
.stdin(Stdio::piped())
|
|
||||||
.stdout(Stdio::piped())
|
|
||||||
.spawn()?;
|
|
||||||
let stdin = child.stdin.as_mut().unwrap();
|
|
||||||
stdin.write_all(code.as_bytes())?;
|
|
||||||
|
|
||||||
let Output {
|
|
||||||
status,
|
|
||||||
stdout,
|
|
||||||
stderr,
|
|
||||||
} = child.wait_with_output()?;
|
|
||||||
if !status.success() {
|
|
||||||
let stderr = String::from_utf8(stderr).unwrap();
|
|
||||||
return Err(io::Error::other(format!(
|
|
||||||
"rustfmt failed: {status:?}\n{stderr}"
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
Ok(String::from_utf8(stdout).unwrap())
|
|
||||||
}
|
|
Loading…
Reference in New Issue