diff options
author | Brett Mandler <brettmandler@gmail.com> | 2020-02-06 19:29:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-06 19:29:57 -0500 |
commit | bc600e4321b525ba5b4e32603b37b18cbc3ea576 (patch) | |
tree | 9b0e1bb78939e2d42c40a8e3f2301dbc033d7e47 /src | |
parent | 2509a791764efaa313a49dc1005796cba067588f (diff) |
feat: Add cabal and hpack detection for the haskell module (#915)
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/haskell.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/modules/haskell.rs b/src/modules/haskell.rs index 93b577d03..7324cc9cc 100644 --- a/src/modules/haskell.rs +++ b/src/modules/haskell.rs @@ -7,10 +7,13 @@ use crate::utils; /// /// Will display the Haskell version if any of the following criteria are met: /// - Current directory contains a `stack.yaml` file +/// - Current directory contains a `.cabal` file +/// - Current directory contains a `package.yaml` file pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { let is_haskell_project = context .try_begin_scan()? - .set_files(&["stack.yaml"]) + .set_files(&["package.yaml", "stack.yaml", "package.yml", "stack.yml"]) + .set_extensions(&["cabal"]) .is_match(); if !is_haskell_project { @@ -52,6 +55,25 @@ mod tests { } #[test] + fn folder_with_hpack_file() -> io::Result<()> { + let dir = tempfile::tempdir()?; + File::create(dir.path().join("package.yaml"))?.sync_all()?; + let actual = render_module("haskell", dir.path()); + let expected = Some(format!("via {} ", Color::Red.bold().paint("λ v8.6.5"))); + assert_eq!(expected, actual); + Ok(()) + } + #[test] + fn folder_with_cabal_file() -> io::Result<()> { + let dir = tempfile::tempdir()?; + File::create(dir.path().join("test.cabal"))?.sync_all()?; + let actual = render_module("haskell", dir.path()); + let expected = Some(format!("via {} ", Color::Red.bold().paint("λ v8.6.5"))); + assert_eq!(expected, actual); + Ok(()) + } + + #[test] fn folder_with_stack_yaml() -> io::Result<()> { let dir = tempfile::tempdir()?; File::create(dir.path().join("stack.yaml"))?.sync_all()?; |