Skip to content

Commit

Permalink
Keep dev server running for non-fatal errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonkearns committed Jan 27, 2020
1 parent dd00f91 commit 5e43bcb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions generator/src/elm-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function run() {
});
}
} else {
if (payload.errors) {
if (payload.errors && payload.errors.length > 0) {
printErrorsAndExit(payload.errors);
}

Expand Down Expand Up @@ -138,7 +138,7 @@ function printErrorsAndExit(errors) {
console.error(
"Found errors. Exiting. Fix your content or parsers and re-run, or run in dev mode with `elm-pages develop`."
);
console.error(errors);
console.error(errors.join("\n\n"));
process.exit(1);
}

Expand Down
32 changes: 18 additions & 14 deletions src/Pages/Internal/Platform/Cli.elm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type alias ToJsSuccessPayload pathKey =
{ pages : Dict String (Dict String String)
, manifest : Manifest.Config pathKey
, filesToGenerate : List FileToGenerate
, errors : List String
}


Expand All @@ -57,13 +58,13 @@ type alias FileToGenerate =
toJsCodec : Codec (ToJsPayload pathKey)
toJsCodec =
Codec.custom
(\errors success value ->
(\errorsTag success value ->
case value of
Errors errorList ->
errors errorList
errorsTag errorList

Success { pages, manifest, filesToGenerate } ->
success (ToJsSuccessPayload pages manifest filesToGenerate)
Success { pages, manifest, filesToGenerate, errors } ->
success (ToJsSuccessPayload pages manifest filesToGenerate errors)
)
|> Codec.variant1 "Errors" Errors Codec.string
|> Codec.variant1 "Success"
Expand Down Expand Up @@ -112,6 +113,7 @@ successCodec =
)
(Decode.succeed [])
)
|> Codec.field "errors" .errors (Codec.list Codec.string)
|> Codec.buildObject


Expand Down Expand Up @@ -847,16 +849,18 @@ sendStaticResponsesIfDone config siteMetadata mode secrets allRawResponses error
in
( updatedAllRawResponses
, SendJsData
(if List.isEmpty allErrors then
Success
(ToJsSuccessPayload
(encodeStaticResponses mode staticResponses)
config.manifest
generatedOkayFiles
)

else
Errors <| BuildError.errorsToString allErrors
(let
buildErrors =
allErrors
|> List.map BuildError.errorToString
in
Success
(ToJsSuccessPayload
(encodeStaticResponses mode staticResponses)
config.manifest
generatedOkayFiles
buildErrors
)
)
)

Expand Down

0 comments on commit 5e43bcb

Please sign in to comment.