diff options
Diffstat (limited to 'compiler/src/Compiler.hs')
-rw-r--r-- | compiler/src/Compiler.hs | 13 |
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 | ||