Skip to content

Commit

Permalink
Move (osIsWindows :: Bool) into Constants
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Jan 31, 2018
1 parent 954711b commit a08ecad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
6 changes: 0 additions & 6 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,6 @@ isOwnedByUser path = liftIO $ do
fileStatus <- getFileStatus (toFilePath path)
user <- getEffectiveUserID
return (user == fileOwner fileStatus)
where
#ifdef WINDOWS
osIsWindows = True
#else
osIsWindows = False
#endif

-- | 'True' if we are currently running inside a Docker container.
getInContainer :: (MonadIO m) => m Bool
Expand Down
11 changes: 11 additions & 0 deletions src/Stack/Constants.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
Expand Down Expand Up @@ -32,6 +33,7 @@ module Stack.Constants
,minTerminalWidth
,maxTerminalWidth
,defaultTerminalWidth
,osIsWindows
)
where

Expand Down Expand Up @@ -241,3 +243,12 @@ maxTerminalWidth = 200
-- automatically detect it and when the user doesn't supply one.
defaultTerminalWidth :: Int
defaultTerminalWidth = 100

-- | True if using Windows OS.
osIsWindows :: Bool
osIsWindows =
#ifdef WINDOWS
True
#else
False
#endif
10 changes: 2 additions & 8 deletions src/Stack/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import qualified Data.Text as T
import Path
import Path.IO
import qualified Stack.Build
import Stack.Constants (osIsWindows)
import Stack.GhcPkg (ghcPkgExeName)
import Stack.Options.ScriptParser
import Stack.Runners
Expand Down Expand Up @@ -122,17 +123,10 @@ scriptCmd opts go' = do
wordsComma = splitWhen (\c -> c == ' ' || c == ',')

toExeName fp =
if isWindows
if osIsWindows
then replaceExtension fp "exe"
else dropExtension fp

isWindows :: Bool
#ifdef WINDOWS
isWindows = True
#else
isWindows = False
#endif

getPackagesFromModuleInfo
:: ModuleInfo
-> FilePath -- ^ script filename
Expand Down

0 comments on commit a08ecad

Please sign in to comment.