@@ -3,6 +3,7 @@ module Reporting.Exit.Crawl
33 ( Exit(..)
44 , Problem(..)
55 , Origin(..)
6+ , SrcDirs(..)
67 , toReport
78 )
89 where
@@ -36,7 +37,7 @@ data Exit
3637
3738
3839data Problem
39− = ModuleNotFound Origin Module.Raw [FilePath]
40+ = ModuleNotFound Origin Module.Raw SrcDirs
4041 | ModuleAmbiguous Origin Module.Raw [FilePath] [Pkg.Package]
4142 | BadHeader FilePath Time.UTCTime BS.ByteString Compiler.Error
4243 | ModuleNameReservedForKernel Origin Module.Raw
@@ -55,6 +56,11 @@ data Origin
5556 | Module FilePath Module.Raw
5657
5758
59+data SrcDirs
60+ = App [FilePath]
61+ | Pkg
62+
63+
5864
5965-- TO REPORT
6066
@@ -113,8 +119,8 @@ toReport exit =
113119problemToReport :: Problem -> Help.Report
114120problemToReport problem =
115121 case problem of
116− ModuleNotFound origin name dirs ->
117− notFoundToDoc origin name dirs
122+ ModuleNotFound origin name srcDirs ->
123+ notFoundToDoc origin name srcDirs
118124
119125 ModuleAmbiguous origin child paths pkgs ->
120126 ambiguousToDoc origin child paths pkgs
@@ -173,7 +179,7 @@ badTagToDoc path name tag hintName summary =
173179
174180
175181
176−-- HELPERS
182+-- NAMELESS
177183
178184
179185namelessToDoc :: FilePath -> Module.Raw -> Help.Report
@@ -194,31 +200,34 @@ namelessToDoc path name =
194200 ]
195201
196202
197−notFoundToDoc :: Origin -> Module.Raw -> [FilePath] -> Help.Report
198−notFoundToDoc origin child dirs =
203+
204+-- NOT FOUND
205+
206+
207+notFoundToDoc :: Origin -> Module.Raw -> SrcDirs -> Help.Report
208+notFoundToDoc origin child srcDirs =
199209 case origin of
200210 ElmJson ->
201211 Help.report "MODULE NOT FOUND" (Just "elm.json")
202212 "Your elm.json says your project has the following module:"
203213 [ D.indent 4 $ D.red $ D.fromString $ Module.nameToString child
204214 , D.reflow $
205− "When creating packages, all modules must live in the\
206− \ src/ directory, but I cannot find it there."
215+ "When creating packages, all modules must live in the src/ directory."
207216 ]
208217
209218 File path ->
210219 Help.report "UNKNOWN IMPORT" (Just path)
211220 ("I cannot find a `" ++ Module.nameToString child ++ "` module to import.")
212− (notFoundDetails child dirs)
221+ (notFoundDetails child srcDirs)
213222
214223 Module path parent ->
215224 Help.report "UNKNOWN IMPORT" (Just path)
216225 ("The " ++ Module.nameToString parent ++ " module has a bad import:")
217− (notFoundDetails child dirs)
226+ (notFoundDetails child srcDirs)
218227
219228
220−notFoundDetails :: Module.Raw -> [FilePath] -> [D.Doc]
221−notFoundDetails child dirs =
229+notFoundDetails :: Module.Raw -> SrcDirs -> [D.Doc]
230+notFoundDetails child srcDirs =
222231 let
223232 simulatedCode =
224233 D.indent 4 $ D.red $ D.fromString $ "import " ++ Module.nameToString child
@@ -230,26 +239,37 @@ notFoundDetails child dirs =
230239 "Do you want the one from the " ++ Pkg.toString pkg
231240 ++ " package? If so, run this command to add that dependency to your elm.json file:"
232241 , D.indent 4 $ D.green $ D.fromString $ "elm install " ++ Pkg.toString pkg
233− , D.reflow $
234− "If you want a local file, make sure the directory that contains the `"
235− ++ Module.nameToString child
236− ++ "` module is listed in your elm.json \"source-directories\" field."
242+ , case srcDirs of
243+ Pkg ->
244+ D.reflow $
245+ "If you want a local file, make sure the `"
246+ ++ Module.nameToString child
247+ ++ "` module is in your src/ directory."
248+
249+ App _ ->
250+ D.reflow $
251+ "If you want a local file, make sure the `"
252+ ++ Module.nameToString child
253+ ++ "` module is in one of the \"source-directories\" listed in your elm.json file."
237254 ]
238255
239256 Nothing ->
240257 [ simulatedCode
241258 , "I cannot find that module! Is there a typo in the module name?"
242259 , D.reflow $
243− case dirs of
244− [] ->
260+ case srcDirs of
261+ Pkg ->
262+ "When creating a package, all modules must live in the src/ directory."
263+
264+ App [] ->
245265 "The \"source-directories\" field of your elm.json is empty, so I only\
246266 \ searched in packages. Maybe you need to add a \"src\" directory there?"
247267
248− [dir] ->
268+ App [dir] ->
249269 "The \"source-directories\" field of your elm.json tells me to only look in the "
250270 ++ dir ++ " directory, but it is not there. Maybe it is in a package that is not installed yet?"
251271
252− dir:_:_ ->
272+ App (dir:_:_) ->
253273 "The \"source-directories\" field of your elm.json tells me to look in directories like "
254274 ++ dir ++ ", but it is not in any of them. Maybe it is in a package that is not installed yet?"
255275 ]