diff --git a/checkmate.nix b/checkmate.nix index 9fa7954..45787f2 100644 --- a/checkmate.nix +++ b/checkmate.nix @@ -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 diff --git a/default.nix b/default.nix index fdfc0cc..ed026b6 100644 --- a/default.nix +++ b/default.nix @@ -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