mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 19:55:03 +01:00
check formatting
This commit is contained in:
parent
1172ce0709
commit
1ef7b906ad
6 changed files with 52 additions and 15 deletions
35
xtask/src/check_fmt.rs
Normal file
35
xtask/src/check_fmt.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use crate::project_root;
|
||||
use anyhow::ensure;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn main() -> anyhow::Result<()> {
|
||||
println!("$ cargo +nightly fmt --check");
|
||||
let status = Command::new("cargo")
|
||||
.arg("+nightly")
|
||||
.arg("fmt")
|
||||
.arg("--check")
|
||||
.current_dir(project_root())
|
||||
.status()?;
|
||||
ensure!(
|
||||
status.success(),
|
||||
"`cargo +nightly fmt --check` did not exit successfully"
|
||||
);
|
||||
|
||||
println!("$ yarn");
|
||||
let status = Command::new("yarn")
|
||||
.arg("check-fmt")
|
||||
.current_dir(project_root().join("test-js"))
|
||||
.status()?;
|
||||
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
||||
|
||||
println!("$ yarn");
|
||||
let status = Command::new("yarn")
|
||||
.arg("check-fmt")
|
||||
.current_dir(project_root().join("amqp_dashboard/frontend"))
|
||||
.status()?;
|
||||
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
||||
|
||||
ensure!(status.success(), "`prettier .` did not exist successfully");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -3,8 +3,9 @@ use anyhow::ensure;
|
|||
use std::process::Command;
|
||||
|
||||
pub fn main() -> anyhow::Result<()> {
|
||||
println!("$ cargo fmt");
|
||||
println!("$ cargo +nightly fmt");
|
||||
let status = Command::new("cargo")
|
||||
.arg("+nightly")
|
||||
.arg("fmt")
|
||||
.current_dir(project_root())
|
||||
.status()?;
|
||||
|
|
@ -17,13 +18,12 @@ pub fn main() -> anyhow::Result<()> {
|
|||
.status()?;
|
||||
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
||||
|
||||
println!("$ prettier -w .");
|
||||
let status = Command::new("prettier")
|
||||
.arg("-w")
|
||||
.arg(".")
|
||||
.current_dir(project_root().join("amqp_dashboard/assets"))
|
||||
println!("$ yarn fmt");
|
||||
let status = Command::new("yarn")
|
||||
.arg("fmt")
|
||||
.current_dir(project_root().join("amqp_dashboard/frontend"))
|
||||
.status()?;
|
||||
ensure!(status.success(), "`prettier .` did not exist successfully");
|
||||
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
mod check_fmt;
|
||||
mod codegen;
|
||||
mod fmt;
|
||||
mod test_js;
|
||||
|
|
@ -21,6 +22,8 @@ enum Commands {
|
|||
TestJs,
|
||||
/// Format all code
|
||||
Fmt,
|
||||
/// Check the formatting
|
||||
CheckFmt,
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
|
|
@ -30,6 +33,7 @@ fn main() -> anyhow::Result<()> {
|
|||
Commands::Generate => codegen::main(),
|
||||
Commands::TestJs => test_js::main(),
|
||||
Commands::Fmt => fmt::main(),
|
||||
Commands::CheckFmt => check_fmt::main(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue