@@ -10,6 +10,7 @@ module Obelisk.Asset.Promoted
1010import Obelisk.Asset.Gather
1111
1212import Data.Foldable
13+import qualified Data.List as L
1314import Language.Haskell.TH (runQ, pprint)
1415import Language.Haskell.TH.Syntax hiding (lift)
1516import GHC.TypeLits
@@ -31,11 +32,15 @@ data StaticConfig = StaticConfig
3132
3233writeStaticProject :: Map FilePath FilePath -> FilePath -> StaticConfig -> IO ()
3334writeStaticProject paths target cfg = do
34− createDirectoryIfMissing True $ target </> "src"
35+ createDirectoryIfMissing True target
3536 T.writeFile (target </> T.unpack (_staticConfig_packageName cfg) <.> "cabal") $ staticCabalFile cfg
3637 let modName = _staticConfig_moduleName cfg
38+ (modName', moduleDirPath) = case L.uncons (reverse $ T.splitOn "." modName) of
39+ Nothing -> error $ "writeStaticProject: invalid module name " <> T.unpack modName
40+ Just (name, parents) -> (name, target </> "src" </> T.unpack (T.intercalate "/" $ reverse parents))
41+ createDirectoryIfMissing True moduleDirPath
3742 modContents <- staticModuleFile modName paths
38− T.writeFile (target </> "src" </> T.unpack modName <.> "hs") modContents
43+ T.writeFile (moduleDirPath </> T.unpack modName' <.> "hs") modContents
3944
4045staticCabalFile :: StaticConfig -> Text
4146staticCabalFile cfg = T.unlines