Skip to content

fix: dont break when given paths that are files. filter on them instead. #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions checkmate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ in
expected = 1;
};

import-tree."test does not break if given a path to a file instead of a directory." = {
expr = lit.leafs ./tree/x/y.nix;
expected = [ ./tree/x/y.nix ];
};

import-tree."test returns a module with a single imported nested module having leafs" = {
expr =
let
Expand Down
9 changes: 8 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ let
lib: root:
let
initialFilter = andNot (lib.hasInfix "/_") (lib.hasSuffix ".nix");
listFilesRecursive = x: if isImportTree x then treeFiles x else lib.filesystem.listFilesRecursive x;
listFilesRecursive =
x:
if isImportTree x then
treeFiles x
else if lib.pathIsDirectory x then
lib.filesystem.listFilesRecursive x
else
[ x ];
treeFiles = t: (t.withLib lib).leafs.result;
in
lib.pipe
Expand Down