From ea56e2e2b89d45c95c60152cbe5e4338e1c997fd Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Thu, 11 Mar 2021 07:47:07 -0800 Subject: [PATCH] feat(build): Use `RUSTFMT` to find `rustfmt` binary (#566) --- tonic-build/src/lib.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tonic-build/src/lib.rs b/tonic-build/src/lib.rs index 3d312a5e7..e3a5acc9b 100644 --- a/tonic-build/src/lib.rs +++ b/tonic-build/src/lib.rs @@ -165,13 +165,14 @@ pub fn fmt(out_dir: &str) { if !file.ends_with(".rs") { continue; } - let result = Command::new("rustfmt") - .arg("--emit") - .arg("files") - .arg("--edition") - .arg("2018") - .arg(format!("{}/{}", out_dir, file)) - .output(); + let result = + Command::new(std::env::var("RUSTFMT").unwrap_or_else(|_| "rustfmt".to_owned())) + .arg("--emit") + .arg("files") + .arg("--edition") + .arg("2018") + .arg(format!("{}/{}", out_dir, file)) + .output(); match result { Err(e) => {