Skip to content

Commit 45ee9e3

Browse files
committed
matchers.json: init
1 parent 0baf224 commit 45ee9e3

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

docs/src/api/matchers.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ Type: `String -> ({ self, super, root, ... } -> Path -> a }) -> Matcher`
4141
Matches files with the given extension.
4242
`matchers.extension "foo"` matches `a.foo` and `a.b.foo`, but not `.foo`.
4343

44+
## `matchers.json`
45+
46+
Source: [`src/matchers/json.nix`](https://github.com/nix-community/haumea/blob/main/src/matchers/json.nix)
47+
48+
Type: `Matcher`
49+
50+
Matches all JSON files and loads them using `lib.importJSON`.
51+
4452
## `matchers.nix`
4553

4654
Source: [`src/matchers/nix.nix`](https://github.com/nix-community/haumea/blob/main/src/matchers/nix.nix)

src/matchers/json.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{ lib, super }:
2+
3+
super.extension "json" (_: lib.importJSON)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"answer": 42
3+
}

tests/matchers/expected.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
baz = {
55
".nix" = ./__fixture/baz/.nix;
66
"foo.yml." = ./__fixture/baz/foo.yml.;
7+
bar.answer = 42;
78
me."me.yaml" = "baz.me";
89
};
910
rest = 42;

tests/matchers/expr.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ haumea.load {
2727
loader = [
2828
(matchers.regex ''^(.+)\.(yaml|yml)$'' fakeLoadYaml)
2929
(matchers.nix haumea.loaders.default)
30+
matchers.json
3031
(matchers.always haumea.loaders.path)
3132
];
3233
}

0 commit comments

Comments
 (0)