Writes the generated spec module to the appropriate file
(name: &str, code: &str)
| 170 | |
| 171 | /// Writes the generated spec module to the appropriate file |
| 172 | fn write_spec_module(name: &str, code: &str) -> Result<()> { |
| 173 | let workspace_root = find_workspace_root()?; |
| 174 | let spec_snake = strip_css_prefix(name).to_snake_case(); |
| 175 | let output_dir = workspace_root.join("crates").join("css_ast").join("src").join("values").join(&spec_snake); |
| 176 | |
| 177 | create_dir_all(&output_dir)?; |
| 178 | |
| 179 | let file_path = output_dir.join("mod.rs"); |
| 180 | write(&file_path, code)?; |
| 181 | println!(" Wrote to {}", file_path.display()); |
| 182 | |
| 183 | Ok(()) |
| 184 | } |
| 185 | |
| 186 | /// Finds the workspace root by searching for Cargo.toml upward from the current directory |
| 187 | fn find_workspace_root() -> Result<PathBuf> { |
no test coverage detected