mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
Minor improvments.
This commit is contained in:
parent
60eb453aad
commit
9f238fa464
3 changed files with 13 additions and 9 deletions
|
@ -21,10 +21,12 @@ impl Plugin {
|
|||
}
|
||||
}
|
||||
Plugin::AppPath {} => {
|
||||
if let Some(v) = crate::plugin::PluginManager::init_plugin_dir().to_str() {
|
||||
println!("{}", v);
|
||||
} else {
|
||||
log::error!("Plugin path get failed.");
|
||||
if let Ok(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: _ } => {
|
||||
|
|
|
@ -42,7 +42,7 @@ impl PluginManager {
|
|||
let manager = lua.create_table().unwrap();
|
||||
let name_index = lua.create_table().unwrap();
|
||||
|
||||
let plugin_dir = Self::init_plugin_dir();
|
||||
let plugin_dir = Self::init_plugin_dir().unwrap();
|
||||
|
||||
let api = lua.create_table().unwrap();
|
||||
|
||||
|
@ -288,15 +288,17 @@ impl PluginManager {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn init_plugin_dir() -> PathBuf {
|
||||
pub fn init_plugin_dir() -> anyhow::Result<PathBuf> {
|
||||
let app_path = app_path();
|
||||
let plugin_path = app_path.join("plugins");
|
||||
if !plugin_path.is_dir() {
|
||||
log::info!("📖 Start to init plugin library ...");
|
||||
let url = "https://github.com/DioxusLabs/cli-plugin-library";
|
||||
clone_repo(&plugin_path, url).unwrap();
|
||||
if let Err(err) = clone_repo(&plugin_path, url) {
|
||||
log::error!("Failed to init plugin dir, error caused by {}. ", err);
|
||||
}
|
||||
}
|
||||
plugin_path
|
||||
Ok(plugin_path)
|
||||
}
|
||||
|
||||
pub fn plugin_list() -> Vec<String> {
|
||||
|
|
|
@ -49,7 +49,7 @@ pub fn clone_repo(dir: &Path, url: &str) -> anyhow::Result<()> {
|
|||
let res = cmd.arg("clone").arg(url).arg(dir_name).output();
|
||||
if let Err(err) = res {
|
||||
if ErrorKind::NotFound == err.kind() {
|
||||
log::error!("Git program not found. Hint: Install git or check $PATH.");
|
||||
log::warn!("Git program not found. Hint: Install git or check $PATH.");
|
||||
return Err(err.into());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue