diff --git a/docs/config/README.md b/docs/config/README.md index 78f05d8f..030ad77d 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -2000,12 +2000,12 @@ The module will be shown if any of the following conditions are met: ### Options -| Option | Default | Description | -| ---------- | ---------------------------------- | ------------------------------------------------------------ | -| `format` | `"via [$symbol$version]($style) "` | The format for the module. | -| `symbol` | `"<=> "` | The symbol used before displaying the version of PureScript. | -| `style` | `"bold white"` | The style for the module. | -| `disabled` | `false` | Disables the `purescript` module. | +| Option | Default | Description | +| ---------- | ------------------------------------ | ------------------------------------------------------------ | +| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | +| `symbol` | `"<=> "` | The symbol used before displaying the version of PureScript. | +| `style` | `"bold white"` | The style for the module. | +| `disabled` | `false` | Disables the `purescript` module. | ### Variables diff --git a/src/configs/purescript.rs b/src/configs/purescript.rs index 4dc01b3d..2696610b 100644 --- a/src/configs/purescript.rs +++ b/src/configs/purescript.rs @@ -13,7 +13,7 @@ pub struct PureScriptConfig<'a> { impl<'a> RootModuleConfig<'a> for PureScriptConfig<'a> { fn new() -> Self { PureScriptConfig { - format: "via [$symbol$version]($style) ", + format: "via [$symbol($version )]($style)", symbol: "<=> ", style: "bold white", disabled: false, diff --git a/src/modules/purescript.rs b/src/modules/purescript.rs index 49dabc58..96d189bb 100644 --- a/src/modules/purescript.rs +++ b/src/modules/purescript.rs @@ -20,8 +20,6 @@ pub fn module<'a>(context: &'a Context) -> Option> { return None; } - let purs_version = utils::exec_cmd("purs", &["--version"])?.stdout; - let mut module = context.new_module("purescript"); let config: PureScriptConfig = PureScriptConfig::try_load(module.config); @@ -36,7 +34,10 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => None, }) .map(|variable| match variable { - "version" => Some(Ok(format!("v{}", purs_version.trim()))), + "version" => { + let purs_version = utils::exec_cmd("purs", &["--version"])?.stdout; + Some(Ok(format!("v{}", purs_version.trim()))) + } _ => None, }) .parse(None) @@ -75,7 +76,7 @@ mod tests { File::create(dir.path().join("Main.purs"))?.sync_all()?; let actual = ModuleRenderer::new("purescript").path(dir.path()).collect(); - let expected = Some(format!("via {} ", Color::White.bold().paint("<=> v0.13.5"))); + let expected = Some(format!("via {}", Color::White.bold().paint("<=> v0.13.5 "))); assert_eq!(expected, actual); dir.close() } @@ -86,7 +87,7 @@ mod tests { File::create(dir.path().join("spago.dhall"))?.sync_all()?; let actual = ModuleRenderer::new("purescript").path(dir.path()).collect(); - let expected = Some(format!("via {} ", Color::White.bold().paint("<=> v0.13.5"))); + let expected = Some(format!("via {}", Color::White.bold().paint("<=> v0.13.5 "))); assert_eq!(expected, actual); dir.close() }