Implement gren format --validate#143
Conversation
| validateFiles :: [FilePath] -> Task.Task Exit.Format () | ||
| validateFiles paths = do | ||
| validationResults <- mapM validateFile paths | ||
| when (any (== False) validationResults) $ | ||
| Task.throw Exit.FormatValidateNotCorrectlyFormatted |
There was a problem hiding this comment.
Currently I check all files before throwing an error so you get a full report.
Is it better to just throw on first invalid file?
There was a problem hiding this comment.
Personally, I think checking all files is good. I often use gren format --validate in CI settings, so I don't necessarily care about how long the validation takes.
There was a problem hiding this comment.
Yeah, checking all seems best, given that this ought to be fast even with lots of files.
|
Tagging @avh4 for review. |
| validateExistingFile path = do | ||
| putStr ("Validating " ++ path) | ||
| original <- File.readUtf8 path | ||
| case formatByteString Parse.Application original of |
There was a problem hiding this comment.
Similar to how formatFile does it, when inputs is Project projectType paths (line 152 above), we should use that projectType instead of Parse.Application. That allows special core modules to be parsed properly. (If you try it on the gren/core library, you should see the problem.)
There was a problem hiding this comment.
I think we need to fix https://github.com/gren-lang/compiler/pull/143/files#r987541415 (the comment above about "projectType") but otherwise this looks great!
Implemented a flag to



gren formatthat checks if files are formatted without modifying them: