1--------------------------------------------------------------------------------
2-- | Implementation of Hakyll commands: build, preview...
15--------------------------------------------------------------------------------
16import System.Exit (ExitCode (ExitSuccess), exitWith)
17import System.Process (system)
20--------------------------------------------------------------------------------
21import qualified Hakyll.Check as Check
22import Hakyll.Core.Configuration
23import Hakyll.Core.Logger (Verbosity)
24import Hakyll.Core.Rules
25import Hakyll.Core.Runtime
26import Hakyll.Core.Util.File
29--------------------------------------------------------------------------------
31import Control.Concurrent (forkIO)
32import qualified Data.Set as S
33import Hakyll.Core.Identifier
34import Hakyll.Core.Rules.Internal
35import Hakyll.Preview.Poll
36import Hakyll.Preview.Server
40--------------------------------------------------------------------------------
42build :: Configuration -> Verbosity -> Rules a -> IO ()
43build conf verbosity rules = do
44 _ <- run conf verbosity rules
48--------------------------------------------------------------------------------
49-- | Run the checker and exit
50check :: Configuration -> Verbosity -> Check.Check -> IO ()
51check config verbosity check' = Check.check config verbosity check' >>= exitWith
54--------------------------------------------------------------------------------
55-- | Remove the output directories
56clean :: Configuration -> IO ()
58 remove $ destinationDirectory conf
59 remove $ storeDirectory conf
60 remove $ tmpDirectory conf
63 putStrLn $ "Removing " ++ dir ++ "..."
67--------------------------------------------------------------------------------
69preview :: Configuration -> Verbosity -> Rules a -> Int -> IO ()
71preview conf verbosity rules port = do
72 -- Run the server in a separate thread
73 _ <- forkIO $ server conf port
74 previewPoll conf update
77 (exitCode, ruleSet) <- run conf verbosity rules
79 ExitSuccess -> return $ map toFilePath $ S.toList $
80 rulesResources ruleSet
81 _ -> exitWith exitCode
83preview _ _ _ _ = previewServerDisabled
87--------------------------------------------------------------------------------
89rebuild :: Configuration -> Verbosity -> Rules a -> IO ()
90rebuild conf verbosity rules = do
92 build conf verbosity rules
95--------------------------------------------------------------------------------
97server :: Configuration -> Int -> IO ()
100 let destination = destinationDirectory conf
101 staticServer destination preServeHook port
103 preServeHook _ = return ()
105server _ _ = previewServerDisabled
109--------------------------------------------------------------------------------
111deploy :: Configuration -> IO ()
113 _ <- system $ deployCommand conf
117--------------------------------------------------------------------------------
118-- | Print a warning message about the preview serving not being enabled
119#ifndef PREVIEW_SERVER
120previewServerDisabled :: IO ()
121previewServerDisabled =
125 , "The preview server is not enabled in the version of Hakyll. To"
126 , "enable it, set the flag to True and recompile Hakyll."
127 , "Alternatively, use an external tool to serve your site directory."
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list