diff options
author | Collin J. Doering <rekahsoft@gmail.com> | 2014-03-23 17:30:29 -0400 |
---|---|---|
committer | Collin J. Doering <rekahsoft@gmail.com> | 2014-03-23 17:30:29 -0400 |
commit | da7ae99b122280849e57fc695bdc67b4433d76b3 (patch) | |
tree | 4c118ae388e26677e63dd99c64e4b37a65e8f9ab | |
parent | 677a7f0f2d6e2daeb57f7897b1f77b0993243839 (diff) | |
download | hakyll-da7ae99b122280849e57fc695bdc67b4433d76b3.tar.gz |
Fix unixFilter on Windows
On windows, the 'unixFilter' function used window's 'createProcess'
function to create the external process that will filter some String
input. The problem with this is that it is unable to execute batch
stubs (eg. anything created using 'gem install ...') even if its in
$PATH. Anyways 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. My solution is to detect windows
using the System.Info module and then instead of using 'proc' to create
the function, use 'shell' instead which will be able to execute
everything 'proc' can + batch files.
Inspired by: http://www.blaenkdenum.com/posts/the-switch-to-hakyll/#scss
Signed-off-by: Collin J. Doering <rekahsoft@gmail.com>
-rw-r--r-- | src/Hakyll/Core/UnixFilter.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Hakyll/Core/UnixFilter.hs b/src/Hakyll/Core/UnixFilter.hs index 34b2ecb..e9a2cc1 100644 --- a/src/Hakyll/Core/UnixFilter.hs +++ b/src/Hakyll/Core/UnixFilter.hs @@ -19,7 +19,7 @@ import System.Exit (ExitCode (..)) import System.IO (Handle, hClose, hFlush, hGetContents, hPutStr, hSetEncoding, localeEncoding) import System.Process - +import System.Info -------------------------------------------------------------------------------- import Hakyll.Core.Compiler @@ -105,8 +105,12 @@ unixFilterIO :: Monoid o -> i -> IO (o, String, ExitCode) unixFilterIO writer reader programName args input = do + let pr = if os == "mingw32" + then shell $ unwords (programName : args) + else proc programName args + (Just inh, Just outh, Just errh, pid) <- - createProcess (proc programName args) + createProcess pr { std_in = CreatePipe , std_out = CreatePipe , std_err = CreatePipe |