File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,12 @@ class Jq extends Operation {
3030 name : "Query" ,
3131 type : "string" ,
3232 value : ""
33- }
33+ } ,
34+ {
35+ name : "Raw" ,
36+ type : "boolean" ,
37+ value : false
38+ } ,
3439 ] ;
3540 }
3641
@@ -41,12 +46,20 @@ class Jq extends Operation {
4146 */
4247 run ( input , args ) {
4348 return ( async ( ) => {
44- const [ query ] = args ;
45- try {
46- const result = await jq . json ( input , query ) ;
47- return JSON . stringify ( result ) ;
48- } catch ( err ) {
49- throw new OperationError ( `Invalid jq expression: ${ err . message } ` ) ;
49+ const [ query , raw ] = args ;
50+ if ( raw ) {
51+ const result = await jq . raw ( input , query , [ "-r" ] ) ;
52+ if ( result . stderr !== "" ) {
53+ throw new OperationError ( `Invalid jq expression: ${ result . stderr } ` ) ;
54+ }
55+ return result . stdout ;
56+ } else {
57+ try {
58+ const result = await jq . json ( input , query ) ;
59+ return JSON . stringify ( result ) ;
60+ } catch ( err ) {
61+ throw new OperationError ( `Invalid jq expression: ${ err . message } ` ) ;
62+ }
5063 }
5164 } ) ( ) ;
5265 }
You can’t perform that action at this time.
0 commit comments