Output Parsing
If you have a command or utility that you want to run pretty much as-is, but Trunk doesn't natively understand how to parse it, you can inject your own custom parser to translate its output into a format that Trunk does understand!
For example, let's say that we want to use grep
as a linter, but we want to add more context to the matches. We could define a custom linter like so:
The execution model that trunk
follows for a parser is that it will:
execute the linter's
run
field, asserting that either:the linter's exit code is in
success_codes
, orthe linter's exit code is not in
error_codes
;
execute
parser.run
,with the
read_output_from
of the linter execution fed toparser.run
asstdin
,assert that the exit code of the parser is 0, and then
use
output
to determine how it should parse the parser'sstdout
.
Node
Remember to run chmod u+x todo-finder-parser.js
so that trunk
can run it!
Last updated