@@ -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
@@ -32,11 +33,15 @@ data StaticConfig = StaticConfig
3233
3334writeStaticProject :: Map FilePath FilePath -> FilePath -> StaticConfig -> IO ()
3435writeStaticProject paths target cfg = do
35− createDirectoryIfMissing True $ target </> "src"
36+ createDirectoryIfMissing True target
3637 T.writeFile (target </> T.unpack (_staticConfig_packageName cfg) <.> "cabal") $ staticCabalFile cfg
3738 let modName = _staticConfig_moduleName cfg
39+ (modName', moduleDirPath) = case L.uncons (reverse $ T.splitOn "." modName) of
40+ Nothing -> error $ "writeStaticProject: invalid module name " <> T.unpack modName
41+ Just (name, parents) -> (name, target </> "src" </> T.unpack (T.intercalate "/" $ reverse parents))
42+ createDirectoryIfMissing True moduleDirPath
3843 modContents <- staticModuleFile modName paths
39− T.writeFile (target </> "src" </> T.unpack modName <.> "hs") modContents
44+ T.writeFile (moduleDirPath </> T.unpack modName' <.> "hs") modContents
4045
4146staticCabalFile :: StaticConfig -> Text
4247staticCabalFile cfg = T.unlines