mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
search for first valid platform in features
This commit is contained in:
parent
f62c81ea0d
commit
3ffb1facf3
1 changed files with 6 additions and 10 deletions
|
@ -2,8 +2,8 @@ use dioxus_cli_config::Platform;
|
|||
use manganis_cli_support::AssetManifest;
|
||||
|
||||
use super::*;
|
||||
use cargo_toml::Dependency::{Detailed, Inherited, Simple};
|
||||
use std::{fs::create_dir_all, io::Write, path::PathBuf};
|
||||
use cargo_toml::Dependency::{Simple, Inherited, Detailed};
|
||||
|
||||
/// Run the WASM project on dev-server
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
|
@ -42,28 +42,24 @@ impl Serve {
|
|||
|
||||
crate_config.set_cargo_args(self.serve.cargo_args);
|
||||
|
||||
let mut platform = self
|
||||
.serve
|
||||
.platform;
|
||||
let mut platform = self.serve.platform;
|
||||
|
||||
if platform.is_none() {
|
||||
if let Some(dependency) = &crate_config.manifest.dependencies.get("dioxus") {
|
||||
let features = match dependency {
|
||||
Inherited(detail) => detail.features.to_vec(),
|
||||
Detailed(detail) => detail.features.to_vec(),
|
||||
Simple(_) => vec![]
|
||||
Simple(_) => vec![],
|
||||
};
|
||||
|
||||
platform = features
|
||||
.iter()
|
||||
.next()
|
||||
.and_then(|first_feature| serde_json::from_str(&format!(r#""{}""#, first_feature)).ok());
|
||||
.find_map(|platform| serde_json::from_str(&format!(r#""{}""#, platform)).ok());
|
||||
}
|
||||
}
|
||||
|
||||
let platform = platform
|
||||
.unwrap_or(crate_config.dioxus_config.application.default_platform);
|
||||
|
||||
let platform = platform.unwrap_or(crate_config.dioxus_config.application.default_platform);
|
||||
|
||||
match platform {
|
||||
Platform::Web => {
|
||||
// start the develop server
|
||||
|
|
Loading…
Add table
Reference in a new issue