avoid updating a file if the old splice is the same as the new
This commit is contained in:
parent
1bf692e67e
commit
0c9bb2371e
1 changed files with 5 additions and 1 deletions
|
@ -35,6 +35,7 @@ import Data.Char
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import System.Directory
|
import System.Directory
|
||||||
|
import Control.Monad
|
||||||
|
|
||||||
import Utility.Monad
|
import Utility.Monad
|
||||||
import Utility.Misc
|
import Utility.Misc
|
||||||
|
@ -179,7 +180,10 @@ applySplices destdir imports l@(first:_) = do
|
||||||
putStrLn $ "splicing " ++ f
|
putStrLn $ "splicing " ++ f
|
||||||
lls <- map (++ "\n") . lines <$> readFileStrict f
|
lls <- map (++ "\n") . lines <$> readFileStrict f
|
||||||
createDirectoryIfMissing True (parentDir dest)
|
createDirectoryIfMissing True (parentDir dest)
|
||||||
writeFile dest $ concat $ addimports $ expand lls l
|
let newcontent = concat $ addimports $ expand lls l
|
||||||
|
oldcontent <- catchMaybeIO $ readFile dest
|
||||||
|
when (oldcontent /= Just newcontent) $
|
||||||
|
writeFile dest newcontent
|
||||||
where
|
where
|
||||||
expand lls [] = lls
|
expand lls [] = lls
|
||||||
expand lls (s:rest) = expand (expandSplice s lls) rest
|
expand lls (s:rest) = expand (expandSplice s lls) rest
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue