Extract the PSR-4 and classmap directory lists from a [`ComposerPackage`] for workspace scanning. This keeps mago types private to this module — callers receive plain strings and don't need to depend on `mago_composer`.
(package: &ComposerPackage)
| 128 | /// This keeps mago types private to this module — callers receive |
| 129 | /// plain strings and don't need to depend on `mago_composer`. |
| 130 | pub fn extract_scan_dirs(package: &ComposerPackage) -> ScanDirs { |
| 131 | let mut psr4 = Vec::new(); |
| 132 | let mut classmap = Vec::new(); |
| 133 | |
| 134 | if let Some(autoload) = &package.autoload { |
| 135 | for (prefix, paths) in &autoload.psr_4 { |
| 136 | let normalised = normalise_prefix(prefix); |
| 137 | paths.for_each_path(|dir| { |
| 138 | psr4.push((normalised.clone(), dir.to_owned())); |
| 139 | }); |
| 140 | } |
| 141 | classmap.extend(autoload.classmap.iter().cloned()); |
| 142 | } |
| 143 | |
| 144 | if let Some(autoload_dev) = &package.autoload_dev { |
| 145 | for (prefix, paths) in &autoload_dev.psr_4 { |
| 146 | let normalised = normalise_prefix(prefix); |
| 147 | paths.for_each_path(|dir| { |
| 148 | psr4.push((normalised.clone(), dir.to_owned())); |
| 149 | }); |
| 150 | } |
| 151 | classmap.extend(autoload_dev.classmap.iter().cloned()); |
| 152 | } |
| 153 | |
| 154 | ScanDirs { psr4, classmap } |
| 155 | } |
| 156 | |
| 157 | /// Read the configured vendor directory from a parsed [`ComposerPackage`]. |
| 158 | /// |
no test coverage detected