@@ -159,6 +159,16 @@ function build() {
159
159
run ( "npm run build" ) ;
160
160
}
161
161
162
+ function prettyJson ( sourceFp : string ) : string {
163
+ return (
164
+ JSON . stringify (
165
+ JSON . parse ( readFileSync ( sourceFp , { encoding : "utf-8" } ) ) ,
166
+ undefined ,
167
+ 2 ,
168
+ ) + "\n"
169
+ ) ;
170
+ }
171
+
162
172
function readPackageJSON ( packageDir ) {
163
173
return JSON . parse (
164
174
readFileSync ( join ( packageDir , "package.json" ) , {
@@ -182,11 +192,9 @@ function diffJson(from: string = "latest", to?: string): string {
182
192
"web-features" ,
183
193
"data.json" ,
184
194
) ;
185
- const prettyJson = execSync ( `jq . "${ pkgJson } "` , {
186
- encoding : "utf-8" ,
187
- } ) ;
195
+ const prettyPkgJson = prettyJson ( pkgJson ) ;
188
196
const fp = join ( temporaryDir , `data.${ version } .json` ) ;
189
- writeFileSync ( fp , prettyJson ) ;
197
+ writeFileSync ( fp , prettyPkgJson ) ;
190
198
return fp ;
191
199
}
192
200
@@ -197,9 +205,7 @@ function diffJson(from: string = "latest", to?: string): string {
197
205
} else {
198
206
build ( ) ;
199
207
const preparedJson = join ( packages [ "web-features" ] , "data.json" ) ;
200
- const prettyPreparedJson = execSync ( `jq . "${ preparedJson } "` , {
201
- encoding : "utf-8" ,
202
- } ) ;
208
+ const prettyPreparedJson = prettyJson ( preparedJson ) ;
203
209
const fp = join ( temporaryDir , "data.HEAD.json" ) ;
204
210
writeFileSync ( fp , prettyPreparedJson ) ;
205
211
return fp ;
@@ -270,16 +276,6 @@ function preflight(options: PreflightOptions): void {
270
276
process . exit ( 1 ) ;
271
277
}
272
278
273
- logger . verbose ( "Confirming jq is installed" ) ;
274
- const jqVersionCmd = "jq --version" ;
275
- try {
276
- logger . debug ( jqVersionCmd ) ;
277
- execSync ( jqVersionCmd ) ;
278
- } catch ( err ) {
279
- logger . error ( "jq failed to run. Do you have it installed?" , err . error ) ;
280
- process . exit ( 1 ) ;
281
- }
282
-
283
279
logger . verbose ( "Checking starting branch" ) ;
284
280
const headCmd = "git rev-parse --abbrev-ref HEAD" ;
285
281
logger . debug ( headCmd ) ;
0 commit comments