From 4d478109a72b4612418adffd28c1cd71d7f9f805 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Mon, 20 Mar 2023 14:31:34 -0700 Subject: [PATCH] fix(scripts): prettify package.json when updating version numbers (#4552) --- scripts/update-versions/updateVersions.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/update-versions/updateVersions.mjs b/scripts/update-versions/updateVersions.mjs index cee548276e6f..2d3fd580f685 100644 --- a/scripts/update-versions/updateVersions.mjs +++ b/scripts/update-versions/updateVersions.mjs @@ -1,6 +1,7 @@ // @ts-check import { readFileSync, writeFileSync } from "fs"; import { join } from "path"; +import { format } from "prettier"; import { getWorkspacePaths } from "../utils/getWorkspacePaths.mjs"; import { getUpdatedPackageJson } from "./getUpdatedPackageJson.mjs"; @@ -10,6 +11,6 @@ export const updateVersions = (depToVersionHash) => { const packageJsonPath = join(workspacePath, "package.json"); const packageJson = JSON.parse(readFileSync(packageJsonPath).toString()); const updatedPackageJson = getUpdatedPackageJson(packageJson, depToVersionHash); - writeFileSync(packageJsonPath, JSON.stringify(updatedPackageJson, null, 2).concat(`\n`)); + writeFileSync(packageJsonPath, format(JSON.stringify(updatedPackageJson), { parser: "json" })); }); };