summaryrefslogtreecommitdiff
path: root/src/Hakyll
diff options
context:
space:
mode:
authorJorge Israel Peña <jorge.israel.p@gmail.com>2014-04-27 15:55:33 -0700
committerJorge Israel Peña <jorge.israel.p@gmail.com>2014-04-27 15:55:33 -0700
commitca44e643a472f7a55fcd8d4deeceebef0679b723 (patch)
treed4e4752a81900da76c079f611e80a32830d6388e /src/Hakyll
parent889b9f95ad17a1203407a992aa4eb1ae9fb54505 (diff)
downloadhakyll-ca44e643a472f7a55fcd8d4deeceebef0679b723.tar.gz
Minor refactor of PR #233
OS won't change mid-execution, so lets avoid the unnecessary check each time `unixFilter` is run.
Diffstat (limited to 'src/Hakyll')
-rw-r--r--src/Hakyll/Core/UnixFilter.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Hakyll/Core/UnixFilter.hs b/src/Hakyll/Core/UnixFilter.hs
index fd3c335..edc8eac 100644
--- a/src/Hakyll/Core/UnixFilter.hs
+++ b/src/Hakyll/Core/UnixFilter.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
--------------------------------------------------------------------------------
-- | A Compiler that supports unix filters.
module Hakyll.Core.UnixFilter
@@ -19,7 +21,6 @@ import System.Exit (ExitCode (..))
import System.IO (Handle, hClose, hFlush, hGetContents,
hPutStr, hSetEncoding, localeEncoding)
import System.Process
-import qualified System.Info as System
--------------------------------------------------------------------------------
import Hakyll.Core.Compiler
@@ -105,17 +106,19 @@ unixFilterIO :: Monoid o
-> i
-> IO (o, String, ExitCode)
unixFilterIO writer reader programName args input = do
- -- The problem on Windows is that `proc` is that it is unable to execute
+ -- The problem on Windows is that `proc` is unable to execute
-- batch stubs (eg. anything created using 'gem install ...') even if its in
-- `$PATH`. A solution to this issue is to execute the batch file explicitly
-- using `cmd /c batchfile` but there is no rational way to know where said
-- batchfile is on the system. Hence, we detect windows using the
- -- `System.Info` module and then instead of using `proc` to create the
- -- process, use `shell` instead which will be able to execute everything
- -- `proc` can, and this can deal with batch files as well.
- let pr = if System.os == "mingw32"
- then shell $ unwords (programName : args)
- else proc programName args
+ -- CPP and instead of using `proc` to create the process, use `shell`
+ -- which will be able to execute everything `proc` can
+ -- as well as batch files.
+#ifdef mingw32_HOST_OS
+ let pr = shell $ unwords (programName : args)
+#else
+ let pr = proc programName args
+#endif
(Just inh, Just outh, Just errh, pid) <-
createProcess pr