Skip to content

Fix crash when running gren package validate. #329

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

Merged
merged 1 commit into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gren.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"direct": {
"gren-lang/core": "6.0.1",
"gren-lang/node": "5.0.4",
"gren-lang/compiler-node": "3.0.1"
"gren-lang/compiler-node": "3.0.2"
},
"indirect": {
"gren-lang/url": "5.0.0"
Expand Down
58 changes: 1 addition & 57 deletions terminal/Package/Validate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ import Gren.Outline qualified as Outline
import Gren.Package qualified as Pkg
import Gren.Version qualified as V
import Reporting qualified
import Reporting.Doc ((<+>))
import Reporting.Doc qualified as D
import Reporting.Exit qualified as Exit
import Reporting.Exit.Help qualified as Help
import Reporting.Task qualified as Task
import System.IO qualified as IO
import System.Info qualified as Info

data Flags = Flags
{ _project_path :: String,
Expand Down Expand Up @@ -64,9 +59,7 @@ validate (Flags root knownVersions (Command.ProjectInfo currentOutline currentSo

verifyBuild :: FilePath -> Outline.PkgOutline -> Build.Sources -> Map Pkg.Name Details.Dependency -> Task.Task Exit.Validate Docs.Documentation
verifyBuild root outline sources solution =
reportBuildCheck $
Task.run $
buildProject root outline sources solution
buildProject root outline sources solution

buildProject :: FilePath -> Outline.PkgOutline -> Build.Sources -> Map Pkg.Name Details.Dependency -> Task.Task Exit.Validate Docs.Documentation
buildProject root pkgOutline@(Outline.PkgOutline _ _ _ _ _ _ _ _) sources solution =
Expand Down Expand Up @@ -111,52 +104,3 @@ verifyBump vsn newDocs oldDocs knownVersions =
return $
Left $
Exit.ValidateBadBump old new magnitude realNew (Diff.toMagnitude changes)

-- REPORTING PHASES

reportBuildCheck :: IO (Either x a) -> Task.Task x a
reportBuildCheck =
reportCheck
"Verifying documentation..."
"Verified documentation"
"Problem with documentation"

reportCheck :: String -> String -> String -> IO (Either x a) -> Task.Task x a
reportCheck waiting success failure work =
reportCustomCheck waiting (\_ -> success) failure work

reportCustomCheck :: String -> (a -> String) -> String -> IO (Either x a) -> Task.Task x a
reportCustomCheck waiting success failure work =
let putFlush doc =
Help.toStdout doc >> IO.hFlush IO.stdout

padded message =
message ++ replicate (length waiting - length message) ' '
in Task.eio id $
do
putFlush $ " " <> waitingMark <+> D.fromChars waiting
result <- work
putFlush $
case result of
Right a -> "\r " <> goodMark <+> D.fromChars (padded (success a) ++ "\n")
Left _ -> "\r " <> badMark <+> D.fromChars (padded failure ++ "\n\n")

return result

-- MARKS

goodMark :: D.Doc
goodMark =
D.green $ if isWindows then "+" else "●"

badMark :: D.Doc
badMark =
D.red $ if isWindows then "X" else "✗"

waitingMark :: D.Doc
waitingMark =
D.dullyellow $ if isWindows then "-" else "→"

isWindows :: Bool
isWindows =
Info.os == "mingw32"