Skip to content

Commit 87dcfa4

Browse files
committed
Fix globbing
1 parent ba1154c commit 87dcfa4

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

dist/npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "whine",
3-
"version": "0.0.15",
3+
"version": "0.0.16",
44
"description": "PureScript linter, extensible, with configurable rules, and one-off escape hatches",
55
"keywords": ["purescript", "lint"],
66
"author": "Fyodor Soikin <name.fa@gmail.com>",

dist/vscode-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "collegevine",
44
"displayName": "Whine at PureScript",
55
"description": "PureScript linter, extensible, with configurable rules, and one-off escape hatches",
6-
"version": "0.0.15",
6+
"version": "0.0.16",
77
"repository": "https://github.com/collegevine/purescript-whine",
88
"engines": {
99
"vscode": "^1.95.0"

spago.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ package:
4343
main: Test.Main
4444
dependencies: []
4545
publish:
46-
version: 0.0.15
46+
version: 0.0.16
4747
license: MIT
4848
location:
4949
githubOwner: collegevine

src/Whine/Runner/Glob.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ foreign import test :: Globs -> FilePath -> Boolean
1010

1111
isEmptyGlobs :: Globs -> Boolean
1212
isEmptyGlobs { include, exclude } = null include && null exclude
13+
14+
emptyGlobs :: Globs
15+
emptyGlobs = { include: [], exclude: [] }

src/Whine/Whine.purs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ checkFile rules path = do
8181
case eText of
8282
Left err ->
8383
tell
84-
[
85-
{ message: "Failed to read the file: " <> Err.message err
84+
[ { message: "Failed to read the file: " <> Err.message err
8685
, source: Nothing
8786
, muted: false
8887
, rule: ""
@@ -130,7 +129,9 @@ checkModule rules { path, text } =
130129
guard $ any (isIntersecting source) rs
131130
pure true
132131

133-
isExcludedByPath v = fromMaybe false do
134-
rule <- Map.lookup v.rule rules
135-
let pathIsOk = Glob.isEmptyGlobs rule.globs || Glob.test rule.globs path
136-
pure $ not pathIsOk
132+
isExcludedByPath v =
133+
let globs = Map.lookup v.rule rules <#> _.globs # fromMaybe Glob.emptyGlobs
134+
included = null globs.include || Glob.test { include: globs.include, exclude: [] } path
135+
excluded = Glob.test { include: globs.exclude, exclude: [] } path
136+
in
137+
excluded || not included

0 commit comments

Comments
 (0)