Skip to content

Commit 16710e6

Browse files
committed
Add import-tree.new
1 parent 4ce0367 commit 16710e6

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ import-tree.pipeTo lib.id # equivalent to `.leafs`
292292
import-tree.leafs
293293
```
294294

295+
### `import-tree.new`
296+
297+
Returns a fresh import-tree with empty state. If you previously had any path, lib, filter, etc,
298+
you might need to set them on the new empty tree.
299+
295300
### `import-tree.result`
296301

297302
Exactly the same as calling the import-tree object with an empty list `[ ]`.

checkmate.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ in
113113
];
114114
};
115115

116+
reset."test `new` returns a clear state" = {
117+
expr = lib.pipe lit [
118+
(i: i.addPath ./tree/x)
119+
(i: i.addPath ./tree/a/b)
120+
(i: i.new)
121+
(i: i.addPath ./tree/modules/hello-world)
122+
(i: i.withLib lib)
123+
(i: i.leafs.result)
124+
];
125+
expected = [ ./tree/modules/hello-world/mod.nix ];
126+
};
127+
116128
addAPI."test extends the API available on an import-tree object" = {
117129
expr =
118130
let

default.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ let
110110

111111
# Applies empty (for already path-configured trees)
112112
result = (self f) [ ];
113+
114+
# returns the original empty state
115+
new = callable;
113116
};
114117
};
115118
in

0 commit comments

Comments
 (0)