From 204c8cc74475461b7262cb9cbfec197b6607c790 Mon Sep 17 00:00:00 2001 From: hirschen Date: Tue, 17 Apr 2012 14:16:32 +0200 Subject: [PATCH] Run the buildhook with 'system' --- yesod/Devel.hs | 19 ++++++++++++++++--- yesod/Types.hs | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/yesod/Devel.hs b/yesod/Devel.hs index 1771f00f..d9c4cd6f 100644 --- a/yesod/Devel.hs +++ b/yesod/Devel.hs @@ -41,7 +41,8 @@ import System.FilePath (splitDirectories, dropExtension, takeExtension import System.Posix.Types (EpochTime) import System.PosixCompat.Files (modificationTime, getFileStatus) import System.Process (createProcess, proc, terminateProcess, readProcess, ProcessHandle, - getProcessExitCode,waitForProcess, rawSystem, runInteractiveProcess) + getProcessExitCode,waitForProcess, rawSystem, + runInteractiveProcess, system) import System.IO (hClose, hIsEOF, hGetLine, stdout, stderr, hPutStrLn) import System.IO.Error (isDoesNotExistError) @@ -111,8 +112,11 @@ devel opts passThroughArgs = do pkgArgs <- ghcPackageArgs opts ghcVer (D.packageDescription gpd) lib let devArgs = pkgArgs ++ ["devel.hs"] ++ passThroughArgs if not success - then putStrLn "Build failure, pausing..." + then do + putStrLn "Build failure, pausing..." + runBuildHook $ failHook opts else do + runBuildHook $ successHook opts removeLock putStrLn $ if verbose opts then "Starting development server: runghc " ++ L.unwords devArgs else "Starting development server..." @@ -125,10 +129,19 @@ devel opts passThroughArgs = do putStrLn "Terminating development server..." terminateProcess ph ec <- waitForProcess' ph - putStrLn $ "Exit code: " ++ show ec Ex.throwTo watchTid (userError "process finished") watchForChanges hsSourceDirs [cabal] list +runBuildHook :: Maybe String -> IO () +runBuildHook m = case m of + Just s -> do + ret <- system s + case ret of + ExitFailure f -> putStrLn $ "Error executing hook: " ++ s + otherwise -> return () + Nothing -> return () + + {- configure with the built-in Cabal lib for non-cabal-dev, since diff --git a/yesod/Types.hs b/yesod/Types.hs index 9c066457..c1d43cd8 100644 --- a/yesod/Types.hs +++ b/yesod/Types.hs @@ -33,7 +33,7 @@ mkOptSuccessHook name = option name (\o -> o , optionShortFlags = ['s'] , optionType = optionTypeMaybe optionTypeString , optionDefault = "" - , optionDescription = "Command to run when compilation succeeds (e.g. 'beep')" + , optionDescription = "Shell command to run when compilation succeeds (e.g. 'beep')" }) mkOptFailHook name = option name (\o -> o @@ -41,7 +41,7 @@ mkOptFailHook name = option name (\o -> o , optionShortFlags = ['f'] , optionType = optionTypeMaybe optionTypeString , optionDefault = "" - , optionDescription = "Command to run when compilation fails (e.g. 'beep')" + , optionDescription = "Shell command to run when compilation fails (e.g. 'beep')" }) mkOptVerbose name = option name (\o -> o