Skip to content

Commit 26552e2

Browse files
authored
release.ts: fix diff buffer full (#2042)
* `release.ts`: fix diff buffer full * Revert "`release.ts`: fix diff buffer full" This reverts commit ec47d74. * `release.ts`: fix diff buffer full * Use consistent casing * Remove spurious comment * Fix use-before-init error
1 parent ee9990b commit 26552e2

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

scripts/release.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ function build() {
159159
run("npm run build");
160160
}
161161

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+
162172
function readPackageJSON(packageDir) {
163173
return JSON.parse(
164174
readFileSync(join(packageDir, "package.json"), {
@@ -182,11 +192,9 @@ function diffJson(from: string = "latest", to?: string): string {
182192
"web-features",
183193
"data.json",
184194
);
185-
const prettyJson = execSync(`jq . "${pkgJson}"`, {
186-
encoding: "utf-8",
187-
});
195+
const prettyPkgJson = prettyJson(pkgJson);
188196
const fp = join(temporaryDir, `data.${version}.json`);
189-
writeFileSync(fp, prettyJson);
197+
writeFileSync(fp, prettyPkgJson);
190198
return fp;
191199
}
192200

@@ -197,9 +205,7 @@ function diffJson(from: string = "latest", to?: string): string {
197205
} else {
198206
build();
199207
const preparedJson = join(packages["web-features"], "data.json");
200-
const prettyPreparedJson = execSync(`jq . "${preparedJson}"`, {
201-
encoding: "utf-8",
202-
});
208+
const prettyPreparedJson = prettyJson(preparedJson);
203209
const fp = join(temporaryDir, "data.HEAD.json");
204210
writeFileSync(fp, prettyPreparedJson);
205211
return fp;
@@ -270,16 +276,6 @@ function preflight(options: PreflightOptions): void {
270276
process.exit(1);
271277
}
272278

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-
283279
logger.verbose("Checking starting branch");
284280
const headCmd = "git rev-parse --abbrev-ref HEAD";
285281
logger.debug(headCmd);

0 commit comments

Comments
 (0)