Fix built-in template rename order
This commit is contained in:
@@ -2,29 +2,6 @@ use crate::error::Result;
|
||||
use serde_json::Value;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
pub fn copy_folder(src: &PathBuf, dest: &PathBuf) -> Result<()> {
|
||||
if !src.exists() || !src.is_dir() {
|
||||
return Err(crate::error::CliError::NotFound(format!(
|
||||
"源目录不存在: {}",
|
||||
src.display()
|
||||
)));
|
||||
}
|
||||
if !dest.exists() {
|
||||
fs::create_dir_all(dest)?;
|
||||
}
|
||||
for entry in fs::read_dir(src)? {
|
||||
let entry = entry?;
|
||||
let src_path = entry.path();
|
||||
let dest_path = dest.join(src_path.file_name().unwrap());
|
||||
if src_path.is_file() {
|
||||
fs::copy(&src_path, &dest_path)?;
|
||||
} else if src_path.is_dir() {
|
||||
copy_folder(&src_path, &dest_path)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn read_file_to_json(path: &PathBuf) -> Result<Value> {
|
||||
let file = fs::read_to_string(path)?;
|
||||
let json: Value = serde_json::from_str(&file)?;
|
||||
|
||||
Reference in New Issue
Block a user