Pretty: handle tilde in paths

This commit is contained in:
Domen Kožar 2018-04-22 15:06:57 +01:00
parent 9937453ef2
commit 7ef7a0bb00
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
2 changed files with 7 additions and 0 deletions

View file

@ -183,6 +183,7 @@ prettyNix = withoutParens . cata phi where
"../" -> "../."
".." -> "../."
txt | "/" `isPrefixOf` txt -> txt
| "~/" `isPrefixOf` txt -> txt
| "./" `isPrefixOf` txt -> txt
| "../" `isPrefixOf` txt -> txt
| otherwise -> "./" ++ txt

View file

@ -24,6 +24,12 @@ case_function_params :: Assertion
case_function_params =
assertPretty (mkFunction (mkParamset [] True) (mkInt 3)) "{ ... }:\n 3"
case_paths :: Assertion
case_paths = do
assertPretty (mkPath False "~/test.nix") "~/test.nix"
assertPretty (mkPath False "/test.nix") "/test.nix"
assertPretty (mkPath False "./test.nix") "./test.nix"
tests :: TestTree
tests = $testGroupGenerator