feat: commit console log

This commit is contained in:
YuKun Liu committed 2022-07-06 21:23:35 +08:00
1 parent 81b712ec0b
commit 61c06ea598
5 files changed
+26 -22

No files matched your search

+5 -1
View File
@@ -13,7 +13,7 @@ use std::{
}; };
use wasm_bindgen_cli_support::Bindgen; use wasm_bindgen_cli_support::Bindgen;
pub fn build(config: &CrateConfig) -> Result<()> { pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> {
// [1] Build the project with cargo, generating a wasm32-unknown-unknown target (is there a more specific, better target to leverage?) // [1] Build the project with cargo, generating a wasm32-unknown-unknown target (is there a more specific, better target to leverage?)
// [2] Generate the appropriate build folders // [2] Generate the appropriate build folders
// [3] Wasm-bindgen the .wasm fiile, and move it into the {builddir}/modules/xxxx/xxxx_bg.wasm // [3] Wasm-bindgen the .wasm fiile, and move it into the {builddir}/modules/xxxx/xxxx_bg.wasm
@@ -52,6 +52,10 @@ pub fn build(config: &CrateConfig) -> Result<()> {
cmd.arg("--verbose"); cmd.arg("--verbose");
} }
if quiet {
cmd.arg("--quiet");
}
if config.custom_profile.is_some() { if config.custom_profile.is_some() {
let custom_profile = config.custom_profile.as_ref().unwrap(); let custom_profile = config.custom_profile.as_ref().unwrap();
cmd.arg("--profile"); cmd.arg("--profile");
+1 -1
View File
@@ -34,7 +34,7 @@ impl Build {
match platform.as_str() { match platform.as_str() {
"web" => { "web" => {
crate::builder::build(&crate_config)?; crate::builder::build(&crate_config, false)?;
} }
"desktop" => { "desktop" => {
crate::builder::build_desktop(&crate_config, false)?; crate::builder::build_desktop(&crate_config, false)?;
+1 -1
View File
@@ -40,7 +40,7 @@ impl Serve {
match platform.as_str() { match platform.as_str() {
"web" => { "web" => {
crate::builder::build(&crate_config)?; crate::builder::build(&crate_config, false)?;
} }
"desktop" => { "desktop" => {
crate::builder::build_desktop(&crate_config, true)?; crate::builder::build_desktop(&crate_config, true)?;
+1 -1
View File
@@ -154,7 +154,7 @@ pub async fn hot_reload_handler(
log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file_path, parse_error.location.line, parse_error.location.column, parse_error.message); log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file_path, parse_error.location.line, parse_error.location.column, parse_error.message);
}, },
Error::RecompileRequiredError(_) => { Error::RecompileRequiredError(_) => {
if let Err(err) = state.build_manager.build(){ if let Err(err) = state.build_manager.rebuild(){
log::error!("{}", err); log::error!("{}", err);
} }
} }
+18 -18
View File
@@ -27,9 +27,9 @@ pub struct BuildManager {
} }
impl BuildManager { impl BuildManager {
fn build(&self) -> Result<()> { fn rebuild(&self) -> Result<()> {
log::info!("🪁 Rebuild code"); log::info!("🪁 Rebuild project");
builder::build(&self.config)?; builder::build(&self.config, true)?;
// change the websocket reload state to true; // change the websocket reload state to true;
// the page will auto-reload. // the page will auto-reload.
if self if self
@@ -158,7 +158,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
} }
if needs_rebuild { if needs_rebuild {
log::info!("reload required"); log::info!("reload required");
if let Err(err) = build_manager.build() { if let Err(err) = build_manager.rebuild() {
log::error!("{}", err); log::error!("{}", err);
} }
} }
@@ -274,7 +274,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> {
if info.is_ok() { if info.is_ok() {
let info = info.unwrap(); let info = info.unwrap();
if chrono::Local::now().timestamp() > last_update_time { if chrono::Local::now().timestamp() > last_update_time {
match build_manager.build() { match build_manager.rebuild() {
Ok(_) => { Ok(_) => {
last_update_time = chrono::Local::now().timestamp(); last_update_time = chrono::Local::now().timestamp();
print_rebuild_info(info.paths); print_rebuild_info(info.paths);
@@ -433,19 +433,19 @@ fn print_console_info(port: u16, config: &CrateConfig) {
} }
fn print_rebuild_info(paths: Vec<PathBuf>) { fn print_rebuild_info(paths: Vec<PathBuf>) {
print!( // print!(
"{}", // "{}",
String::from_utf8_lossy( // String::from_utf8_lossy(
&Command::new(if cfg!(target_os = "windows") { // &Command::new(if cfg!(target_os = "windows") {
"cls" // "cls"
} else { // } else {
"clear" // "clear"
}) // })
.output() // .output()
.unwrap() // .unwrap()
.stdout // .stdout
) // )
); // );
for path in paths { for path in paths {
let path = path.strip_prefix(crate::crate_root().unwrap()).unwrap().to_path_buf(); let path = path.strip_prefix(crate::crate_root().unwrap()).unwrap().to_path_buf();