summaryrefslogtreecommitdiff
path: root/Propellor/Property/File.hs
diff options
context:
space:
mode:
authorJoey Hess2014-04-13 14:01:30 -0400
committerJoey Hess2014-04-13 14:01:30 -0400
commit1495db6cd103bf5f9f4635dbbfe807c7c1f39b2e (patch)
treef01d5ee3b99cc9609cdcefb0fc4076c4b9bb5e91 /Propellor/Property/File.hs
parentf428ccd9b1fa32fac7415910021be8f51f66857c (diff)
propellor spin
Diffstat (limited to 'Propellor/Property/File.hs')
-rw-r--r--Propellor/Property/File.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/Propellor/Property/File.hs b/Propellor/Property/File.hs
index bd33c9b8..8f23dab7 100644
--- a/Propellor/Property/File.hs
+++ b/Propellor/Property/File.hs
@@ -31,11 +31,14 @@ hasPrivContentExposed f = hasPrivContent f `onChange`
-- | Ensures that a line is present in a file, adding it to the end if not.
containsLine :: FilePath -> Line -> Property
-f `containsLine` l = fileProperty (f ++ " contains:" ++ l) go f
+f `containsLine` l = f `containsLines` [l]
+
+containsLines :: FilePath -> [Line] -> Property
+f `containsLines` l = fileProperty (f ++ " contains:" ++ show l) go f
where
go ls
- | l `elem` ls = ls
- | otherwise = ls++[l]
+ | all (`elem` ls) l = ls
+ | otherwise = ls++l
-- | Ensures that a line is not present in a file.
-- Note that the file is ensured to exist, so if it doesn't, an empty