fix(cmake): Fix spacing with missing variable (#2135)
This fixes the additional space when the `version` variable can't be populated.
This commit is contained in:
parent
5722b17f9e
commit
12494da38a
|
@ -444,12 +444,12 @@ The `cmake` module shows the currently installed version of CMake if any of the
|
|||
|
||||
### Options
|
||||
|
||||
| Option | Default | Description |
|
||||
| ---------- | ---------------------------------- | -------------------------------------------- |
|
||||
| `format` | `"via [$symbol$version]($style) "` | The format for the module. |
|
||||
| `symbol` | `"喝 "` | The symbol used before the version of cmake. |
|
||||
| `style` | `"bold blue"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `cmake` module. |
|
||||
| Option | Default | Description |
|
||||
| ---------- | ------------------------------------ | -------------------------------------------- |
|
||||
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
|
||||
| `symbol` | `"喝 "` | The symbol used before the version of cmake. |
|
||||
| `style` | `"bold blue"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `cmake` module. |
|
||||
|
||||
### Variables
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct CMakeConfig<'a> {
|
|||
impl<'a> RootModuleConfig<'a> for CMakeConfig<'a> {
|
||||
fn new() -> Self {
|
||||
CMakeConfig {
|
||||
format: "via [$symbol$version]($style) ",
|
||||
format: "via [$symbol($version )]($style)",
|
||||
symbol: "喝 ",
|
||||
style: "bold blue",
|
||||
disabled: false,
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::utils;
|
|||
/// Creates a module with the current CMake version
|
||||
///
|
||||
/// Will display the CMake version if any of the following criteria are met:
|
||||
/// - The current directory contains a `CMakeLists.txt` file
|
||||
/// - The current directory contains a `CMakeLists.txt` or `CMakeCache.txt`
|
||||
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
let is_cmake_project = context
|
||||
.try_begin_scan()?
|
||||
|
@ -77,7 +77,7 @@ mod tests {
|
|||
let dir = tempfile::tempdir()?;
|
||||
File::create(dir.path().join("CMakeLists.txt"))?.sync_all()?;
|
||||
let actual = ModuleRenderer::new("cmake").path(dir.path()).collect();
|
||||
let expected = Some(format!("via {} ", Color::Blue.bold().paint("喝 v3.17.3")));
|
||||
let expected = Some(format!("via {}", Color::Blue.bold().paint("喝 v3.17.3 ")));
|
||||
assert_eq!(expected, actual);
|
||||
dir.close()
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ mod tests {
|
|||
let dir = tempfile::tempdir()?;
|
||||
File::create(dir.path().join("CMakeCache.txt"))?.sync_all()?;
|
||||
let actual = ModuleRenderer::new("cmake").path(dir.path()).collect();
|
||||
let expected = Some(format!("via {} ", Color::Blue.bold().paint("喝 v3.17.3")));
|
||||
let expected = Some(format!("via {}", Color::Blue.bold().paint("喝 v3.17.3 ")));
|
||||
assert_eq!(expected, actual);
|
||||
dir.close()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue