Skip to content

Commit f3d5649

Browse files
committed
Deduplicate jq compilation logic
newJQWriter now delegates to compileJQ so parse+compile options are maintained in one place.
1 parent 4b02ec3 commit f3d5649

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

internal/commands/jq.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@ type jqWriter struct {
1818
}
1919

2020
// newJQWriter parses and compiles the jq expression and returns a filtering writer.
21-
// Compilation includes gojq.WithEnvironLoader for env.VAR / $ENV.VAR access.
21+
// Delegates to compileJQ for compilation so options are maintained in one place.
2222
func newJQWriter(dest io.Writer, filter string) (*jqWriter, error) {
23-
query, err := gojq.Parse(filter)
24-
if err != nil {
25-
return nil, errors.ErrJQValidation(err)
26-
}
27-
code, err := gojq.Compile(query, gojq.WithEnvironLoader(os.Environ))
23+
code, err := compileJQ(filter)
2824
if err != nil {
29-
return nil, errors.ErrJQValidation(err)
25+
return nil, err
3026
}
3127
return &jqWriter{dest: dest, code: code}, nil
3228
}

0 commit comments

Comments
 (0)