Skip to content

Commit 760965c

Browse files
committed
Check if target might be a project.
1 parent 540dd1f commit 760965c

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/Stack/Build/Target.hs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE DataKinds #-}
33
{-# LANGUAGE GADTs #-}
4+
{-# LANGUAGE MultiWayIf #-}
45
{-# LANGUAGE OverloadedStrings #-}
56
{-# LANGUAGE ViewPatterns #-}
67

@@ -153,11 +154,26 @@ parseRawTargetDirs root locals ri =
153154
mdir <- liftIO $ forgivingAbsence (resolveDir root (T.unpack t))
154155
>>= rejectMissingDir
155156
case mdir of
156-
Nothing -> pure $ Left $
157-
fillSep
158-
[ flow "Directory not found:"
159-
, style Dir (fromString $ T.unpack t) <> "."
160-
]
157+
Nothing -> pure . Left $
158+
if | T.isPrefixOf "stack-yaml" t ->
159+
fillSep
160+
[ flow "Directory not found:"
161+
, style Dir (fromString $ T.unpack t) <> "."
162+
, flow "Is this a typo? Can I suggest:"
163+
, style Dir (fromString $ "--" ++ T.unpack t)
164+
]
165+
| T.isSuffixOf ".yaml" t ->
166+
fillSep
167+
[ flow "Directory not found:"
168+
, style Dir (fromString $ T.unpack t) <> "."
169+
, flow "Is this a typo? Can I suggest:"
170+
, style Dir (fromString $ "--stack-yaml " ++ T.unpack t)
171+
]
172+
| otherwise ->
173+
fillSep
174+
[ flow "Directory not found:"
175+
, style Dir (fromString $ T.unpack t) <> "."
176+
]
161177
Just dir ->
162178
case mapMaybe (childOf dir) $ Map.toList locals of
163179
[] -> pure $ Left $

0 commit comments

Comments
 (0)