Skip to content

Commit a08ecad

Browse files
committed
Move (osIsWindows :: Bool) into Constants
1 parent 954711b commit a08ecad

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

src/Stack/Config.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,6 @@ isOwnedByUser path = liftIO $ do
768768
fileStatus <- getFileStatus (toFilePath path)
769769
user <- getEffectiveUserID
770770
return (user == fileOwner fileStatus)
771-
where
772-
#ifdef WINDOWS
773-
osIsWindows = True
774-
#else
775-
osIsWindows = False
776-
#endif
777771

778772
-- | 'True' if we are currently running inside a Docker container.
779773
getInContainer :: (MonadIO m) => m Bool

src/Stack/Constants.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE NoImplicitPrelude #-}
23
{-# LANGUAGE OverloadedStrings #-}
34
{-# LANGUAGE TemplateHaskell #-}
@@ -32,6 +33,7 @@ module Stack.Constants
3233
,minTerminalWidth
3334
,maxTerminalWidth
3435
,defaultTerminalWidth
36+
,osIsWindows
3537
)
3638
where
3739

@@ -241,3 +243,12 @@ maxTerminalWidth = 200
241243
-- automatically detect it and when the user doesn't supply one.
242244
defaultTerminalWidth :: Int
243245
defaultTerminalWidth = 100
246+
247+
-- | True if using Windows OS.
248+
osIsWindows :: Bool
249+
osIsWindows =
250+
#ifdef WINDOWS
251+
True
252+
#else
253+
False
254+
#endif

src/Stack/Script.hs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import qualified Data.Text as T
1616
import Path
1717
import Path.IO
1818
import qualified Stack.Build
19+
import Stack.Constants (osIsWindows)
1920
import Stack.GhcPkg (ghcPkgExeName)
2021
import Stack.Options.ScriptParser
2122
import Stack.Runners
@@ -122,17 +123,10 @@ scriptCmd opts go' = do
122123
wordsComma = splitWhen (\c -> c == ' ' || c == ',')
123124

124125
toExeName fp =
125-
if isWindows
126+
if osIsWindows
126127
then replaceExtension fp "exe"
127128
else dropExtension fp
128129

129-
isWindows :: Bool
130-
#ifdef WINDOWS
131-
isWindows = True
132-
#else
133-
isWindows = False
134-
#endif
135-
136130
getPackagesFromModuleInfo
137131
:: ModuleInfo
138132
-> FilePath -- ^ script filename

0 commit comments

Comments
 (0)