Skip to content

Commit ea56e2e

Browse files
authored
feat(build): Use RUSTFMT to find rustfmt binary (#566)
1 parent 61555ff commit ea56e2e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tonic-build/src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,14 @@ pub fn fmt(out_dir: &str) {
165165
if !file.ends_with(".rs") {
166166
continue;
167167
}
168-
let result = Command::new("rustfmt")
169-
.arg("--emit")
170-
.arg("files")
171-
.arg("--edition")
172-
.arg("2018")
173-
.arg(format!("{}/{}", out_dir, file))
174-
.output();
168+
let result =
169+
Command::new(std::env::var("RUSTFMT").unwrap_or_else(|_| "rustfmt".to_owned()))
170+
.arg("--emit")
171+
.arg("files")
172+
.arg("--edition")
173+
.arg("2018")
174+
.arg(format!("{}/{}", out_dir, file))
175+
.output();
175176

176177
match result {
177178
Err(e) => {

0 commit comments

Comments
 (0)