Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No output seen when doc format is missing/has errors #45

Open
hpate-triller opened this issue Mar 9, 2021 · 0 comments
Open

No output seen when doc format is missing/has errors #45

hpate-triller opened this issue Mar 9, 2021 · 0 comments

Comments

@hpate-triller
Copy link

hpate-triller commented Mar 9, 2021

First, thank you for this project, I love being able to browse the docs for our application!

I ran into an issue where when we have some files with incorrect or missing documentation, edp doesn't list the errors that need to be fixed in the documentation.

In our case it was failed to parse the string that comes back from running elm make

 |> stubbing incoming port uiVideoPlayerInbound
  |> stubbing outgoing port uiVideoPlayerOutbound
SyntaxError: Unexpected token n in JSON at position 1899
  |> writing documentation into docs.json
failed to build project documentation

I added some additional logging and it looks like this line is where it is happening: https://github.com/dmy/elm-doc-preview/blob/master/lib/elm-doc-server.ts#L328

In the output in ends up getting something like

{"type":"compile-errors","errors":[....the rest of the error json}npm ERR! code 1
npm ERR! path /Users/user/path/to/project/elm-stuff/elm-application-482575LMmitR960sw
npm ERR! command failed
npm ERR! command sh -c elm "make" "--docs=/var/folders/h5/nv96dt4j2rs9rhh4zxq4gjjw0000gn/T/elm-docs-48257qjjrw5ZuSXCo.json" "--report=json"
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2021-03-09T14_51_44_781Z-debug.log

It is those additional npm ERR! strings that cause the parsing to fail, I tweaked the code on that line to strip out anything after npm ERR!, and that seems to solve it.

    let replacedStr = build.stderr.toString().replace(/npm ERR! .*/gm, "");
    elmErrors(JSON.parse(replacedStr));

node version: v15.1.0
npm version: 7.5.2
OS: MacOS Catalina 10.15.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant