From 70c51d29fcdad762ebb6a3de078d5d8427fb5cdd Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 12 Mar 2015 09:15:49 +0200 Subject: [PATCH] nocopyto switch (closes #952) --- yesod-bin/ChangeLog.md | 4 ++++ yesod-bin/Keter.hs | 5 +++-- yesod-bin/main.hs | 11 ++++++++--- yesod-bin/yesod-bin.cabal | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/yesod-bin/ChangeLog.md b/yesod-bin/ChangeLog.md index 065a54c1..11d50f2f 100644 --- a/yesod-bin/ChangeLog.md +++ b/yesod-bin/ChangeLog.md @@ -1,3 +1,7 @@ +## 1.4.5 + +* add a switch to yesod to skip deploying a .keter with copy-to [#952](https://github.com/yesodweb/yesod/issues/952) + ## 1.4.4 * Add and process Keter option 'extraFiles' [#947](https://github.com/yesodweb/yesod/pull/947) diff --git a/yesod-bin/Keter.hs b/yesod-bin/Keter.hs index 65ff7802..e0dbdc6a 100644 --- a/yesod-bin/Keter.hs +++ b/yesod-bin/Keter.hs @@ -27,8 +27,9 @@ run a b = do keter :: String -- ^ cabal command -> Bool -- ^ no build? + -> Bool -- ^ no copy to? -> IO () -keter cabal noBuild = do +keter cabal noBuild noCopyTo = do ketercfg <- keterConfig mvalue <- decodeFile ketercfg value <- @@ -78,7 +79,7 @@ keter cabal noBuild = do let fp = T.unpack project ++ ".keter" L.writeFile fp $ compress $ Tar.write archive - case Map.lookup "copy-to" value of + unless noCopyTo $ case Map.lookup "copy-to" value of Just (String s) -> case parseMaybe (.: "copy-to-port") value of Just i -> run "scp" ["-P" ++ show (i :: Int), fp, T.unpack s] diff --git a/yesod-bin/main.hs b/yesod-bin/main.hs index 9a7c948f..968c52c5 100755 --- a/yesod-bin/main.hs +++ b/yesod-bin/main.hs @@ -60,7 +60,10 @@ data Command = Init { _initBare :: Bool } } | Test | AddHandler - | Keter { _keterNoRebuild :: Bool } + | Keter + { _keterNoRebuild :: Bool + , _keterNoCopyTo :: Bool + } | Version deriving (Show, Eq) @@ -96,7 +99,7 @@ main = do Configure -> cabal ["configure"] Build es -> touch' >> cabal ("build":es) Touch -> touch' - Keter noRebuild -> keter (cabalCommand o) noRebuild + Keter{..} -> keter (cabalCommand o) _keterNoRebuild _keterNoCopyTo Version -> putStrLn ("yesod-bin version: " ++ showVersion Paths_yesod_bin.version) AddHandler -> addHandler Test -> cabalTest cabal @@ -144,7 +147,9 @@ optParser = Options ) keterOptions :: Parser Command -keterOptions = Keter <$> switch ( long "nobuild" <> short 'n' <> help "Skip rebuilding" ) +keterOptions = Keter + <$> switch ( long "nobuild" <> short 'n' <> help "Skip rebuilding" ) + <*> switch ( long "nocopyto" <> help "Ignore copy-to directive in keter config file" ) defaultRescan :: Int defaultRescan = 10 diff --git a/yesod-bin/yesod-bin.cabal b/yesod-bin/yesod-bin.cabal index a5b1a653..b62b2aa6 100644 --- a/yesod-bin/yesod-bin.cabal +++ b/yesod-bin/yesod-bin.cabal @@ -1,5 +1,5 @@ name: yesod-bin -version: 1.4.4 +version: 1.4.5 license: MIT license-file: LICENSE author: Michael Snoyman