Skip to content

Commit 4ce0367

Browse files
vicCopilot
andauthored
fix: dont break when given paths that are files. filter on them instead. (#13)
* fix: dont break when given paths that are files. filter on them instead. * Update default.nix Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update checkmate.nix Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fmt --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 6aab7a2 commit 4ce0367

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

checkmate.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ in
138138
expected = 1;
139139
};
140140

141+
import-tree."test does not break if given a path to a file instead of a directory." = {
142+
expr = lit.leafs ./tree/x/y.nix;
143+
expected = [ ./tree/x/y.nix ];
144+
};
145+
141146
import-tree."test returns a module with a single imported nested module having leafs" = {
142147
expr =
143148
let

default.nix

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ let
2929
lib: root:
3030
let
3131
initialFilter = andNot (lib.hasInfix "/_") (lib.hasSuffix ".nix");
32-
listFilesRecursive = x: if isImportTree x then treeFiles x else lib.filesystem.listFilesRecursive x;
32+
listFilesRecursive =
33+
x:
34+
if isImportTree x then
35+
treeFiles x
36+
else if lib.pathIsDirectory x then
37+
lib.filesystem.listFilesRecursive x
38+
else
39+
[ x ];
3340
treeFiles = t: (t.withLib lib).leafs.result;
3441
in
3542
lib.pipe

0 commit comments

Comments
 (0)