mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 11:45:02 +01:00
add yarn install to formatting
This commit is contained in:
parent
4f5f9d6513
commit
8070cfc2a9
4 changed files with 43 additions and 20 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::project_root;
|
use crate::{project_root, yarn_install};
|
||||||
use anyhow::ensure;
|
use anyhow::ensure;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
|
@ -14,21 +14,29 @@ pub fn main() -> anyhow::Result<()> {
|
||||||
"`cargo fmt --check` did not exit successfully"
|
"`cargo fmt --check` did not exit successfully"
|
||||||
);
|
);
|
||||||
|
|
||||||
println!("$ yarn");
|
let test_js = project_root().join("test-js");
|
||||||
|
yarn_install(&test_js)?;
|
||||||
|
println!("$ yarn check-fmt");
|
||||||
let status = Command::new("yarn")
|
let status = Command::new("yarn")
|
||||||
.arg("check-fmt")
|
.arg("check-fmt")
|
||||||
.current_dir(project_root().join("test-js"))
|
.current_dir(test_js)
|
||||||
.status()?;
|
.status()?;
|
||||||
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
ensure!(
|
||||||
|
status.success(),
|
||||||
|
"`yarn check-fmt` did not exist successfully"
|
||||||
|
);
|
||||||
|
|
||||||
println!("$ yarn");
|
let frontend = project_root().join("amqp_dashboard/frontend");
|
||||||
|
yarn_install(&frontend)?;
|
||||||
|
println!("$ yarn check-fmt");
|
||||||
let status = Command::new("yarn")
|
let status = Command::new("yarn")
|
||||||
.arg("check-fmt")
|
.arg("check-fmt")
|
||||||
.current_dir(project_root().join("amqp_dashboard/frontend"))
|
.current_dir(frontend)
|
||||||
.status()?;
|
.status()?;
|
||||||
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
ensure!(
|
||||||
|
status.success(),
|
||||||
ensure!(status.success(), "`prettier .` did not exist successfully");
|
"`yarn check-fmt` did not exist successfully"
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::project_root;
|
use crate::{project_root, yarn_install};
|
||||||
use anyhow::ensure;
|
use anyhow::ensure;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
|
@ -10,17 +10,21 @@ pub fn main() -> anyhow::Result<()> {
|
||||||
.status()?;
|
.status()?;
|
||||||
ensure!(status.success(), "`cargo fmt` did not exit successfully");
|
ensure!(status.success(), "`cargo fmt` did not exit successfully");
|
||||||
|
|
||||||
|
let test_js = project_root().join("test-js");
|
||||||
|
yarn_install(&test_js)?;
|
||||||
println!("$ yarn fmt");
|
println!("$ yarn fmt");
|
||||||
let status = Command::new("yarn")
|
let status = Command::new("yarn")
|
||||||
.arg("fmt")
|
.arg("fmt")
|
||||||
.current_dir(project_root().join("test-js"))
|
.current_dir(test_js)
|
||||||
.status()?;
|
.status()?;
|
||||||
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
||||||
|
|
||||||
|
let frontend = project_root().join("amqp_dashboard/frontend");
|
||||||
|
yarn_install(&frontend)?;
|
||||||
println!("$ yarn fmt");
|
println!("$ yarn fmt");
|
||||||
let status = Command::new("yarn")
|
let status = Command::new("yarn")
|
||||||
.arg("fmt")
|
.arg("fmt")
|
||||||
.current_dir(project_root().join("amqp_dashboard/frontend"))
|
.current_dir(frontend)
|
||||||
.status()?;
|
.status()?;
|
||||||
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
ensure!(status.success(), "`yarn fmt` did not exist successfully");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
use std::path::PathBuf;
|
use anyhow::{ensure, Context, Result};
|
||||||
|
use std::{
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
process::Command,
|
||||||
|
};
|
||||||
|
|
||||||
mod check_fmt;
|
mod check_fmt;
|
||||||
mod codegen;
|
mod codegen;
|
||||||
|
|
@ -43,3 +47,14 @@ pub fn project_root() -> PathBuf {
|
||||||
.expect("project root path")
|
.expect("project root path")
|
||||||
.to_path_buf()
|
.to_path_buf()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn yarn_install(path: &Path) -> Result<()> {
|
||||||
|
let status = Command::new("yarn")
|
||||||
|
.arg("install")
|
||||||
|
.current_dir(path)
|
||||||
|
.status()
|
||||||
|
.context("run yarn install failed")?;
|
||||||
|
|
||||||
|
ensure!(status.success(), "Failed to build frontend");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::project_root;
|
use crate::{project_root, yarn_install};
|
||||||
use anyhow::{ensure, Context, Result};
|
use anyhow::{ensure, Context, Result};
|
||||||
use std::{path::Path, process::Command, thread::sleep, time::Duration};
|
use std::{path::Path, process::Command, thread::sleep, time::Duration};
|
||||||
|
|
||||||
|
|
@ -29,12 +29,8 @@ pub fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_js(test_js_root: &Path) -> Result<()> {
|
fn run_js(test_js_root: &Path) -> Result<()> {
|
||||||
println!("$ yarn");
|
yarn_install(test_js_root)?;
|
||||||
let status = Command::new("yarn")
|
|
||||||
.current_dir(&test_js_root)
|
|
||||||
.status()
|
|
||||||
.context("yarn install tests")?;
|
|
||||||
ensure!(status.success(), "yarn install failed");
|
|
||||||
println!("$ yarn test");
|
println!("$ yarn test");
|
||||||
let status = Command::new("yarn")
|
let status = Command::new("yarn")
|
||||||
.arg("test")
|
.arg("test")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue