Skip to content

Commit

Permalink
Minor config fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Feb 12, 2012
1 parent fa0b44f commit fc8ffbb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/Angel.hs
Expand Up @@ -11,6 +11,7 @@ import Data.Text.Lazy.Builder.Int (decimal)
import Filesystem.Path.CurrentOS (encodeString)
import qualified Data.Map as Map
import Data.Text (Text, pack, unpack)
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import Control.Monad.Trans.State (StateT, runStateT, get, put)
import Control.Monad.IO.Class (liftIO)
Expand All @@ -21,6 +22,7 @@ import Config
import Paths
import Filesystem (isFile)
import System.Process (readProcess)
import Data.Char (isAlphaNum)

infixr 5 <>
(<>) :: Monoid m => m -> m -> m
Expand All @@ -29,11 +31,14 @@ infixr 5 <>
-- | A block in an angel file for an individual webapp.
angelBlock :: WebappFinal -> Builder
angelBlock (WebappFinal w d p mpost) =
fromText (deployName d) <> "-" <> fromText (webappHost w) <> " {\n" <>
" exec = \"env PORT=" <> decimal p <> " " <> postgresEnv <> fromString (encodeString $ webappExec w) <> "\"\n" <>
fromText (deployName d) <> "-" <> fromText (T.map safeChar $ webappHost w) <> " {\n" <>
" exec = \"env PORT=" <> decimal p <> " " <> postgresEnv <> fromString (encodeString $ webappExec w) <> " production\"\n" <>
" directory = \"" <> fromString (encodeString $ deployDirectory d) <> "\"\n" <>
"}\n\n"
where
safeChar c
| isAlphaNum c = c
| otherwise = '_'
postgresEnv =
case mpost of
Nothing -> ""
Expand Down
6 changes: 3 additions & 3 deletions src/Config.hs
Expand Up @@ -52,9 +52,9 @@ instance FromJSON Deploy where
parseJSON (Object o) = Deploy
<$> o .: "name"
<*> return ""
<*> o .: "webapps"
<*> o .: "statics"
<*> o .: "postgresql"
<*> o .:? "webapps" .!= []
<*> o .:? "statics" .!= []
<*> o .:? "postgresql" .!= False
parseJSON _ = mzero

instance FromJSON Webapp where
Expand Down

0 comments on commit fc8ffbb

Please sign in to comment.