summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Vetter <moritz.vetter@gmx.de>2021-01-22 18:01:54 +0100
committerGitHub <noreply@github.com>2021-01-22 18:01:54 +0100
commit60be1e9540e5739d45bd06b0de8abbc51ded8661 (patch)
treebc05aedb579090b499a789f394b12d0ac716fd5d
parent499e0357b0c1badb93334f6dbfb94a94120f723d (diff)
Perf(purescript): Lazy eval purescript (#2191)
* perf(purescript): evaluate version lazily * fix(purescript): update format string; update tests Co-authored-by: Moritz Vetter <mv@3yourmind.com>
-rw-r--r--docs/config/README.md12
-rw-r--r--src/configs/purescript.rs2
-rw-r--r--src/modules/purescript.rs11
3 files changed, 13 insertions, 12 deletions
diff --git a/docs/config/README.md b/docs/config/README.md
index 78f05d8f3..030ad77df 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 4dc01b3d4..2696610b0 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 49dabc588..96d189bbd 100644
--- a/src/modules/purescript.rs
+++ b/src/modules/purescript.rs
@@ -20,8 +20,6 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
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<Module<'a>> {
_ => 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()
}