|
1 | | -use log::{Level, LevelFilter, Log, Metadata, Record, debug, error, warn}; |
| 1 | +use log::{debug, error, warn, Level, LevelFilter, Log, Metadata, Record}; |
2 | 2 | use owo_colors::{OwoColorize, Style}; |
3 | 3 | use std::os::unix::fs::PermissionsExt; |
4 | 4 | use std::sync::mpsc; |
@@ -153,7 +153,34 @@ fn enqueue_readme_jobs(sender: std::sync::mpsc::Sender<Job>) { |
153 | 153 |
|
154 | 154 | // Also handle the workspace/top-level README, if any |
155 | 155 | let workspace_template_path = workspace_dir.join(template_name); |
156 | | - process_readme_template(&workspace_template_path, &workspace_dir, "facet"); |
| 156 | + |
| 157 | + // Get workspace name from cargo tree |
| 158 | + let workspace_name = match Command::new("cargo") |
| 159 | + .arg("tree") |
| 160 | + .stdout(Stdio::piped()) |
| 161 | + .stderr(Stdio::piped()) |
| 162 | + .spawn() |
| 163 | + .and_then(|child| { |
| 164 | + let output = child.wait_with_output()?; |
| 165 | + if output.status.success() { |
| 166 | + let stdout = String::from_utf8_lossy(&output.stdout); |
| 167 | + if let Some(first_line) = stdout.lines().next() { |
| 168 | + // Extract package name from "package-name v0.1.0 (/path/to/package)" |
| 169 | + if let Some(space_pos) = first_line.find(' ') { |
| 170 | + return Ok(first_line[..space_pos].to_string()); |
| 171 | + } |
| 172 | + } |
| 173 | + } |
| 174 | + Err(std::io::Error::other("Failed to parse cargo tree output")) |
| 175 | + }) { |
| 176 | + Ok(name) => name, |
| 177 | + Err(e) => { |
| 178 | + warn!("Failed to get workspace name from cargo tree: {e}, falling back to 'facet'"); |
| 179 | + "facet".to_string() |
| 180 | + } |
| 181 | + }; |
| 182 | + |
| 183 | + process_readme_template(&workspace_template_path, &workspace_dir, &workspace_name); |
157 | 184 | } |
158 | 185 |
|
159 | 186 | fn enqueue_rustfmt_jobs(sender: std::sync::mpsc::Sender<Job>, staged_files: &StagedFiles) { |
|
0 commit comments