Commit ca34285b authored by Armin Bernstetter's avatar Armin Bernstetter
Browse files

added feature to remove old resource folders

parent 453fbd32
......@@ -59,8 +59,7 @@ main = do
" (branch: " ++
deckerGitBranch ++
", commit: " ++
deckerGitCommitId ++
", tag: " ++ deckerGitVersionTag ++ ")"
deckerGitCommitId ++ ", tag: " ++ deckerGitVersionTag ++ ")"
putNormal $ "pandoc version " ++ pandocVersion
putNormal $ "pandoc-types version " ++ showVersion pandocTypesVersion
--
......@@ -166,6 +165,8 @@ main = do
phony "clean" $ do
removeFilesAfter (directories ^. public) ["//"]
removeFilesAfter (directories ^. project) cruft
old <- liftIO getOldResources
forM_ old $ \dir -> removeFilesAfter dir ["//"]
when isDevelopmentVersion $
removeFilesAfter (directories ^. appData) ["//"]
--
......
......@@ -5,6 +5,7 @@ module Resources
, deckerResourceDir
, writeExampleProject
, copyDir
, getOldResources
) where
import Common
......@@ -17,6 +18,7 @@ import System.Environment
import System.Exit
import System.FilePath
import System.Process
import Text.Regex.TDFA
deckerResourceDir :: IO FilePath
deckerResourceDir =
......@@ -25,6 +27,19 @@ deckerResourceDir =
("decker" ++
"-" ++ deckerVersion ++ "-" ++ deckerGitBranch ++ "-" ++ deckerGitCommitId)
getOldResources :: IO [FilePath]
getOldResources = do
dir <- takeDirectory <$> deckerResourceDir
files <- listDirectory dir
return $ map (dir </>) $ filter oldVersion files
where
current = deckerVersion
deckerRegex = "decker-([0-9]+[.][0-9]+[.][0-9]+)-[.]*" :: String
oldVersion name =
case getAllTextSubmatches (name =~ deckerRegex) :: [String] of
x:v:xs -> v < current
[] -> False
getResourceString :: FilePath -> IO String
getResourceString path = do
dataDir <- deckerResourceDir
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment