Skip to content

Commit

Permalink
Merge branch 'master' into e2e-custom-fee-token
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx authored Oct 22, 2024
2 parents f08047e + 0654a93 commit d7e0104
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/scripts/src/addOrbitChain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
updateAndValidateOrbitChainsList,
commitChangesAndCreatePR,
setOutputs,
runPrettier,
} from "./transforms";

/**
Expand Down Expand Up @@ -36,6 +37,8 @@ export async function addOrbitChain(targetJsonPath: string): Promise<void> {
targetJsonPath
);

await runPrettier(targetJsonPath);

await commitChangesAndCreatePR(
branchName,
targetJsonPath,
Expand Down
16 changes: 16 additions & 0 deletions packages/scripts/src/addOrbitChain/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -437,3 +438,18 @@ export const updateOrbitChainsFile = (

return orbitChains;
};

export async function runPrettier(targetJsonPath: string): Promise<void> {
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}`);
}
}

0 comments on commit d7e0104

Please sign in to comment.