1
1
mirror of https://github.com/nmattia/snack.git synced 2025-01-07 13:47:09 +03:00

Merge pull request #90 from 2mol/2mol-fix-regex

fix .hs file matching
This commit is contained in:
Nicolas Mattia 2018-10-21 14:31:09 +02:00 committed by GitHub
commit 4df17e3efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 2 deletions

View File

@ -20,6 +20,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
### Fixed
- The module import parsing when the CPP extension is enabled.
- The module import parsing when a BOM is present
- The module import parsing when a BOM is present.
- The matching on Haskell files. Any file in any subdirectory ending in `.hs` will be matched, both lower- and uppercase filenames are accepted.
[Unreleased]: https://github.com/nmattia/snack/compare/51987daf76cffc31289e6913174dfb46b93df36b...HEAD

View File

@ -39,7 +39,7 @@ rec {
# Whether the file is a Haskell module or not. It uses very simple
# heuristics: If the file starts with a capital letter, then yes.
isHaskellModuleFile = f:
! (builtins.isNull (builtins.match "[A-Z].*" f));
! (builtins.isNull (builtins.match "[a-zA-Z].*[.]hs$" (builtins.baseNameOf f)));
listModulesInDir = dir:
map fileToModule

3
tests/swp/golden.jq Normal file
View File

@ -0,0 +1,3 @@
[
"Foo.Bar"
]

3
tests/swp/package.nix Normal file
View File

@ -0,0 +1,3 @@
{ src = ./src;
dependencies = [ "conduit" ];
}

Binary file not shown.

9
tests/swp/src/Foo/Bar.hs Normal file
View File

@ -0,0 +1,9 @@
module Bar where
import Conduit
spitOut :: ConduitT () Int IO ()
spitOut = yieldMany [ 1 ..]
digest :: ConduitT Int Void IO ()
digest = mapM_C print

14
tests/swp/test Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# vim: ft=sh sw=2 et
set -euo pipefail
test() {
TMP_FILE=$(mktemp)
cat $($SNACK build) | jq -M '.result | keys' > $TMP_FILE
diff golden.jq $TMP_FILE
}
SNACK="snack -j4" test