fix: format code

This commit is contained in:
YuKun Liu committed 2023-05-23 13:47:18 -07:00
1 parent 719015378b
commit aa1a45a14e
5 files changed
+21 -27

No files matched your search

+8 -14
View File
@@ -49,7 +49,8 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
// [1] Build the .wasm module
log::info!("🚅 Running build command...");
let cmd = subprocess::Exec::cmd("cargo");
let cmd = cmd.cwd(&crate_dir)
let cmd = cmd
.cwd(&crate_dir)
.arg("build")
.arg("--target")
.arg("wasm32-unknown-unknown")
@@ -66,25 +67,18 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
cmd
};
let cmd = if quiet {
cmd.arg("--quiet")
} else {
cmd
};
let cmd = if quiet { cmd.arg("--quiet") } else { cmd };
let cmd = if config.custom_profile.is_some() {
let custom_profile = config.custom_profile.as_ref().unwrap();
cmd
.arg("--profile")
.arg(custom_profile)
cmd.arg("--profile").arg(custom_profile)
} else {
cmd
};
let cmd = if config.features.is_some() {
let features_str = config.features.as_ref().unwrap().join(" ");
cmd.arg("--features")
.arg(features_str)
cmd.arg("--features").arg(features_str)
} else {
cmd
};
@@ -394,9 +388,9 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
let message = msg.message;
match message.level {
cargo_metadata::diagnostic::DiagnosticLevel::Error => {
return Err(anyhow::anyhow!(
message.rendered.unwrap_or("Unknown".into())
));
return Err(anyhow::anyhow!(message
.rendered
.unwrap_or("Unknown".into())));
}
cargo_metadata::diagnostic::DiagnosticLevel::Warning => {
warning_messages.push(message.clone());
+3 -1
View File
@@ -34,7 +34,9 @@ pub fn crate_root() -> Result<PathBuf> {
}
None
})
.ok_or_else(|| Error::CargoError("Failed to find directory containing Cargo.toml".to_string()))
.ok_or_else(|| {
Error::CargoError("Failed to find directory containing Cargo.toml".to_string())
})
}
/// Checks if the directory contains `Cargo.toml`
+1 -2
View File
@@ -21,14 +21,13 @@ impl Plugin {
}
}
Plugin::AppPath {} => {
if let Ok(plugin_dir) = crate::plugin::PluginManager::init_plugin_dir() {
let plugin_dir = crate::plugin::PluginManager::init_plugin_dir();
if let Some(v) = plugin_dir.to_str() {
println!("{}", v);
} else {
log::error!("Plugin path get failed.");
}
}
}
Plugin::Add { name: _ } => {
log::info!("You can use `dioxus plugin app-path` to get Installation position");
}
+8 -9
View File
@@ -136,7 +136,12 @@ pub async fn hot_reload_handler(
}
#[allow(unused_assignments)]
pub async fn startup_hot_reload(ip: String, port: u16, config: CrateConfig, start_browser: bool) -> Result<()> {
pub async fn startup_hot_reload(
ip: String,
port: u16,
config: CrateConfig,
start_browser: bool,
) -> Result<()> {
let first_build_result = crate::builder::build(&config, false)?;
log::info!("🚀 Starting development server...");
@@ -296,10 +301,7 @@ pub async fn startup_hot_reload(ip: String, port: u16, config: CrateConfig, star
HeaderName::from_static("cross-origin-embedder-policy"),
coep,
)
.override_response_header(
HeaderName::from_static("cross-origin-opener-policy"),
coop,
)
.override_response_header(HeaderName::from_static("cross-origin-opener-policy"), coop)
.and_then(
move |response: Response<ServeFileSystemResponseBody>| async move {
let response = if file_service_config
@@ -480,10 +482,7 @@ pub async fn startup_default(
HeaderName::from_static("cross-origin-embedder-policy"),
coep,
)
.override_response_header(
HeaderName::from_static("cross-origin-opener-policy"),
coop,
)
.override_response_header(HeaderName::from_static("cross-origin-opener-policy"), coop)
.and_then(
move |response: Response<ServeFileSystemResponseBody>| async move {
let response = if file_service_config
+1 -1
View File
@@ -1,6 +1,6 @@
use std::{
fs::{create_dir_all, File},
io::{Read, Write, ErrorKind},
io::{ErrorKind, Read, Write},
path::{Path, PathBuf},
process::Command,
};