Skip to content

Commit

Permalink
fix(build): Remove debug println! (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
alce committed Mar 27, 2020
1 parent 224280d commit e2c2be2
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tonic-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ pub mod prost;
pub mod schema;

#[cfg(feature = "rustfmt")]
use std::process::Command;
use std::io::{self, Write};
#[cfg(feature = "rustfmt")]
use std::process::{exit, Command};

/// Serivce code generation for client
/// Service code generation for client
pub mod client;
/// Serivce code generation for Server
/// Service code generation for Server
pub mod server;

/// Format files under the out_dir with rustfmt
Expand All @@ -83,17 +85,26 @@ pub fn fmt(out_dir: &str) {
if !file.ends_with(".rs") {
continue;
}
let out = Command::new("rustfmt")
let result = Command::new("rustfmt")
.arg("--emit")
.arg("files")
.arg("--edition")
.arg("2018")
.arg(format!("{}/{}", out_dir, file))
.output()
.unwrap();
.output();

println!("out: {:?}", out);
assert!(out.status.success());
match result {
Err(e) => {
eprintln!("error running rustfmt: {:?}", e);
exit(1)
}
Ok(output) => {
if !output.status.success() {
io::stderr().write_all(&output.stderr).unwrap();
exit(output.status.code().unwrap_or(1))
}
}
}
}
}

Expand Down

0 comments on commit e2c2be2

Please sign in to comment.