diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-10-23 15:43:06 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-10-23 15:43:06 -0400 |
| commit | 42ed4b5e68ec84106850c07904ee6124a7805742 (patch) | |
| tree | 9e49ef3e9a8d02d1951e07d1c31119e5eb7d5844 /src/Propellor/Property/File.hs | |
| parent | 3f17dd7cbef4ec6bbccc368e07be964dc7f9570b (diff) | |
| parent | 3aee86abac10f1ad9d4b51c024f5f3c02cdbfc68 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/File.hs')
| -rw-r--r-- | src/Propellor/Property/File.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Propellor/Property/File.hs b/src/Propellor/Property/File.hs index 7e421cb7..3476bad0 100644 --- a/src/Propellor/Property/File.hs +++ b/src/Propellor/Property/File.hs @@ -70,6 +70,13 @@ f `lacksLine` l = fileProperty (f ++ " remove: " ++ l) (filter (/= l)) f lacksLines :: FilePath -> [Line] -> Property NoInfo f `lacksLines` ls = fileProperty (f ++ " remove: " ++ show [ls]) (filter (`notElem` ls)) f +-- | Replaces the content of a file with the transformed content of another file +basedOn :: FilePath -> (FilePath, [Line] -> [Line]) -> Property NoInfo +f `basedOn` (f', a) = property desc $ go =<< (liftIO $ readFile f') + where + desc = "replace " ++ f + go tmpl = ensureProperty $ fileProperty desc (\_ -> a $ lines $ tmpl) f + -- | Removes a file. Does not remove symlinks or non-plain-files. notPresent :: FilePath -> Property NoInfo notPresent f = check (doesFileExist f) $ property (f ++ " not present") $ |
