From 62877cbba043cecc9a58586eb22299a38036f4e7 Mon Sep 17 00:00:00 2001 From: Maximilian Tagher Date: Fri, 6 Jun 2014 12:51:00 -0700 Subject: [PATCH] In `yesod init`, ensure words have atleast one character; fixes #550 --- yesod-bin/Scaffolding/Scaffolder.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/yesod-bin/Scaffolding/Scaffolder.hs b/yesod-bin/Scaffolding/Scaffolder.hs index daa76c8c..0ccfa02c 100644 --- a/yesod-bin/Scaffolding/Scaffolder.hs +++ b/yesod-bin/Scaffolding/Scaffolder.hs @@ -15,6 +15,8 @@ import Text.ProjectTemplate (unpackTemplate, receiveFS) import System.IO import Text.Shakespeare.Text (renderTextUrl, textFile) import Network.HTTP.Conduit (withManager, http, parseUrl, responseBody) +import Data.List.Split (splitOn) +import Data.Char (isDigit) prompt :: (String -> Maybe a) -> IO a prompt f = do @@ -68,12 +70,14 @@ validPN c validPN '-' = True validPN _ = False + + scaffold :: Bool -- ^ bare directory instead of a new subdirectory? -> IO () scaffold isBare = do puts $ renderTextUrl undefined $(textFile "input/welcome.cg") project <- prompt $ \s -> - if all validPN s && not (null s) && s /= "test" + if all validPN s && not (null s) && s /= "test" && (not $ any (all isDigit) (splitOn "-" s)) then Just s else Nothing let dir = project