Skip to content

Commit

Permalink
Fix to the fix of "stack config set" #2709
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Feb 1, 2017
1 parent 98f2843 commit fa3ed94
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/Stack/ConfigCmd.hs
Expand Up @@ -14,7 +14,6 @@ module Stack.ConfigCmd
,cfgCmdName) where

import Control.Applicative
import Control.Exception
import Control.Monad
import Control.Monad.Catch (throwM)
import Control.Monad.IO.Class
Expand All @@ -24,15 +23,15 @@ import qualified Data.HashMap.Strict as HMap
import Data.Monoid
import Data.Text (Text)
import qualified Data.Text as T
import Data.Typeable
import qualified Data.Yaml as Yaml
import qualified Options.Applicative as OA
import qualified Options.Applicative.Types as OA
import Path
import Path.IO
import Prelude -- Silence redundant import warnings
import Stack.BuildPlan
import Stack.Config (makeConcreteResolver, getProjectConfig)
import Stack.Config (makeConcreteResolver, getProjectConfig, getImplicitGlobalProjectDir)
import Stack.Constants
import Stack.Types.Config
import Stack.Types.Resolver

Expand All @@ -49,16 +48,6 @@ data CommandScope
-- typically at @~/.stack/config.yaml@.
| CommandScopeProject
-- ^ Apply changes to the project @stack.yaml@.
deriving (Show)

data ConfigCmdError
= ExpectedLocalProject
deriving (Typeable)

instance Exception ConfigCmdError
instance Show ConfigCmdError where
show ExpectedLocalProject =
"Since --global was not used, expected to find a local project configuration. However, none was found."

configCmdSetScope :: ConfigCmdSet -> CommandScope
configCmdSetScope (ConfigCmdSetResolver _) = CommandScopeProject
Expand All @@ -79,9 +68,8 @@ cfgCmdSet go cmd = do
mstackYaml <- getProjectConfig mstackYamlOption
case mstackYaml of
Just stackYaml -> return stackYaml
Nothing -> throwM ExpectedLocalProject
Nothing -> liftM (</> stackDotYaml) (getImplicitGlobalProjectDir conf)
CommandScopeGlobal -> return (configUserConfigPath conf))
liftIO $ print (configCmdSetScope cmd, configFilePath)
-- We don't need to worry about checking for a valid yaml here
(config :: Yaml.Object) <-
liftIO (Yaml.decodeFileEither configFilePath) >>= either throwM return
Expand Down

0 comments on commit fa3ed94

Please sign in to comment.