theme_importer: Format generated themes (#3255)
This PR makes the `theme_importer` format the themes that it generates automatically. Release Notes: - N/A
This commit is contained in:
parent
64b899c68c
commit
25876161f8
14 changed files with 68 additions and 4 deletions
|
@ -5,6 +5,7 @@ mod vscode;
|
|||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
|
@ -152,6 +153,9 @@ fn main() -> Result<()> {
|
|||
|
||||
let theme_module = format!(
|
||||
r#"
|
||||
// This file was generated by the `theme_importer`.
|
||||
// Be careful when modifying it by hand.
|
||||
|
||||
use gpui::rgba;
|
||||
|
||||
use crate::{{
|
||||
|
@ -174,7 +178,7 @@ fn main() -> Result<()> {
|
|||
r#"
|
||||
use crate::UserThemeFamily;
|
||||
|
||||
pub(crate) fn all_imported_themes() -> Vec<UserThemeFamily> {{
|
||||
pub(crate) fn all_user_themes() -> Vec<UserThemeFamily> {{
|
||||
vec![{all_themes}]
|
||||
}}
|
||||
"#,
|
||||
|
@ -187,6 +191,9 @@ fn main() -> Result<()> {
|
|||
|
||||
let mod_rs_contents = format!(
|
||||
r#"
|
||||
// This file was generated by the `theme_importer`.
|
||||
// Be careful when modifying it by hand.
|
||||
|
||||
{mod_statements}
|
||||
|
||||
{use_statements}
|
||||
|
@ -208,5 +215,23 @@ fn main() -> Result<()> {
|
|||
|
||||
mod_rs_file.write_all(mod_rs_contents.as_bytes())?;
|
||||
|
||||
println!("Formatting themes...");
|
||||
|
||||
let format_result = format_themes_crate()
|
||||
// We need to format a second time to catch all of the formatting issues.
|
||||
.and_then(|_| format_themes_crate());
|
||||
|
||||
if let Err(err) = format_result {
|
||||
eprintln!("Failed to format themes: {}", err);
|
||||
}
|
||||
|
||||
println!("Done!");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn format_themes_crate() -> std::io::Result<std::process::Output> {
|
||||
Command::new("cargo")
|
||||
.args(["fmt", "--package", "theme2"])
|
||||
.output()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue