aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Compiler.hs
diff options
context:
space:
mode:
authorpacien2019-12-27 10:21:44 +0100
committerpacien2019-12-27 10:21:44 +0100
commit015d793b25a3f0d1ff275ed42ec211dd6a532ca0 (patch)
tree3b6f5b96631c4f8575ce32a0a07b647ebbedc0a4 /compiler/src/Compiler.hs
parenteb7a652b2244ffa4dd5ba2440b7879127e7c6078 (diff)
downloadldgallery-015d793b25a3f0d1ff275ed42ec211dd6a532ca0.tar.gz
compiler: fix old resources cleanup
Diffstat (limited to 'compiler/src/Compiler.hs')
-rw-r--r--compiler/src/Compiler.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs
index 9767394..991de9c 100644
--- a/compiler/src/Compiler.hs
+++ b/compiler/src/Compiler.hs
@@ -71,16 +71,15 @@ compileGallery inputDirPath outputDirPath =
71 putStrLn "\nRESOURCE TREE" 71 putStrLn "\nRESOURCE TREE"
72 putStrLn (show resourceTree) 72 putStrLn (show resourceTree)
73 73
74 --cleanup resourceTree outputDirPath 74 cleanup resourceTree outputDirPath
75 75
76 buildGalleryTree resourceTree 76 buildGalleryTree resourceTree
77 & ensureParentDir JSON.encodeFile (outputDirPath </> "index.json") 77 & writeJSON (outputDirPath </> "index.json")
78 78
79 viewer config 79 viewer config
80 & ensureParentDir JSON.encodeFile (outputDirPath </> "viewer.json") 80 & writeJSON (outputDirPath </> "viewer.json")
81 81
82 where 82 where
83 -- TODO: delete all files, then only non-empty dirs
84 cleanup :: ResourceTree -> FileName -> IO () 83 cleanup :: ResourceTree -> FileName -> IO ()
85 cleanup resourceTree outputDir = 84 cleanup resourceTree outputDir =
86 readDirectory outputDir 85 readDirectory outputDir
@@ -94,3 +93,9 @@ compileGallery inputDirPath outputDirPath =
94 do 93 do
95 putStrLn $ "Removing: " ++ path 94 putStrLn $ "Removing: " ++ path
96 removePathForcibly path 95 removePathForcibly path
96
97 writeJSON :: ToJSON a => FileName -> a -> IO ()
98 writeJSON outputPath object =
99 do
100 putStrLn $ "Generating: " ++ outputPath
101 ensureParentDir JSON.encodeFile outputPath object