39 lines
1.2 KiB
Rust
39 lines
1.2 KiB
Rust
use crate::prelude::*;
|
|
use std::process::Stdio;
|
|
use tokio::{
|
|
io::{AsyncBufReadExt, BufReader},
|
|
process::Command,
|
|
};
|
|
|
|
#[instrument]
|
|
pub fn start_watcher() {
|
|
info!("starting");
|
|
match Command::new("tailwindcss")
|
|
.args(["-i", "src/style.css", "-o", "static/style.css", "--watch"])
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped())
|
|
.spawn()
|
|
{
|
|
Ok(mut tw) => {
|
|
info!("spawned");
|
|
let mut stdout_reader = BufReader::new(tw.stdout.take().unwrap()).lines();
|
|
tokio::spawn(async move {
|
|
while let Ok(Some(l)) = stdout_reader.next_line().await {
|
|
if l.trim().len() > 0 {
|
|
event!(target: "tailwind::stdout", Level::INFO, "{l}");
|
|
}
|
|
}
|
|
});
|
|
let mut stderr_reader = BufReader::new(tw.stderr.take().unwrap()).lines();
|
|
tokio::spawn(async move {
|
|
while let Ok(Some(l)) = stderr_reader.next_line().await {
|
|
if l.trim().len() > 0 {
|
|
event!(target: "tailwind::stderr", Level::INFO, "{l}");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
Err(e) => error!("Failed to spawn Tailwind: {e}"),
|
|
}
|
|
}
|