haskell-servant / servant-elm

Automatically derive Elm functions to query servant webservices
BSD 3-Clause "New" or "Revised" License
164 stars 48 forks source link

Creating output directory automatically #40

Closed saurabhnanda closed 6 years ago

saurabhnanda commented 6 years ago

I was trying out servant-elm for the first time, and kept running into this issue:

Prelude Elm CodeGen> specsToDir specs "/tmp/elm"
Writing: /tmp/elm/AutoGenerated/Api.elm
*** Exception: /tmp/elm/AutoGenerated/Api.elm: openFile: does not exist (No such file or directory)

It would be a good idea to use the equivalent of mkdir -p to create the output directory.

popara commented 6 years ago

You have to have folder structure in place in order for writeFile to write-a-file. It doesn't create directories for you.

Hence

md /tmp/elm:)

mattjbray commented 6 years ago

Hi @saurabhnanda. Thanks for the issue. specsToDir actually comes from https://github.com/krisajenkins/elm-export, so if you think the behaviour could be improved then please file an issue over there.