diff --git a/packages/scripts/src/addOrbitChain/index.ts b/packages/scripts/src/addOrbitChain/index.ts index 64d66647f0..13ce85c114 100644 --- a/packages/scripts/src/addOrbitChain/index.ts +++ b/packages/scripts/src/addOrbitChain/index.ts @@ -8,6 +8,7 @@ import { updateAndValidateOrbitChainsList, commitChangesAndCreatePR, setOutputs, + runPrettier, } from "./transforms"; /** @@ -36,6 +37,8 @@ export async function addOrbitChain(targetJsonPath: string): Promise { targetJsonPath ); + await runPrettier(targetJsonPath); + await commitChangesAndCreatePR( branchName, targetJsonPath, diff --git a/packages/scripts/src/addOrbitChain/transforms.ts b/packages/scripts/src/addOrbitChain/transforms.ts index b90ee3893e..4a8c499a97 100644 --- a/packages/scripts/src/addOrbitChain/transforms.ts +++ b/packages/scripts/src/addOrbitChain/transforms.ts @@ -8,6 +8,7 @@ import { JsonRpcProvider } from "@ethersproject/providers"; import axios from "axios"; import * as fs from "fs"; import sharp from "sharp"; +import prettier from "prettier"; import { commitChanges, @@ -437,3 +438,18 @@ export const updateOrbitChainsFile = ( return orbitChains; }; + +export async function runPrettier(targetJsonPath: string): Promise { + try { + const fileContent = fs.readFileSync(targetJsonPath, "utf8"); + const prettierConfig = await prettier.resolveConfig(targetJsonPath); + const formattedContent = await prettier.format(fileContent, { + ...prettierConfig, + filepath: targetJsonPath, + }); + fs.writeFileSync(targetJsonPath, formattedContent); + console.log(`Prettier formatting applied to ${targetJsonPath}`); + } catch (error) { + warning(`Failed to run Prettier: ${error}`); + } +}