Load plugin paths from .ts/.js files in {plugin,plugins}/*.{ts,js}
(dir: &Path)
| 657 | |
| 658 | /// Load plugin paths from .ts/.js files in {plugin,plugins}/*.{ts,js} |
| 659 | fn load_plugins_from_dir(dir: &Path) -> Vec<String> { |
| 660 | let mut plugins = Vec::new(); |
| 661 | |
| 662 | for subdir_name in &["plugin", "plugins"] { |
| 663 | let subdir = dir.join(subdir_name); |
| 664 | if !subdir.is_dir() { |
| 665 | continue; |
| 666 | } |
| 667 | if let Ok(entries) = fs::read_dir(&subdir) { |
| 668 | for entry in entries.flatten() { |
| 669 | let path = entry.path(); |
| 670 | if let Some(ext) = path.extension() { |
| 671 | if ext == "ts" || ext == "js" { |
| 672 | // Convert to file:// URL like TS does |
| 673 | let url = format!("file://{}", path.display()); |
| 674 | plugins.push(url); |
| 675 | } |
| 676 | } |
| 677 | } |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | plugins |
| 682 | } |
| 683 | |
| 684 | /// Recursively find all .md files in a directory. |
| 685 | fn glob_md_files(dir: &Path) -> Result<Vec<PathBuf>> { |