Skip to content

Commit

Permalink
use SOLIDITY_FRAMEWORKS variable instead of hardcoding
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Jun 26, 2024
1 parent 09fa8c0 commit 277e55c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/tasks/prettier-format.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { execa } from "execa";
import path from "path";
import { Options } from "../types";
import { SOLIDITY_FRAMEWORKS } from "../utils/consts";

export async function prettierFormat(targetDir: string, options: Options) {
try {
const nextJsPath = path.join(targetDir, "/packages/nextjs");
const nextJsPath = path.join(targetDir, "packages", "nextjs");
const nextPrettierConfig = path.join(nextJsPath, ".prettierrc.json");
const result = await execa("yarn", [
"prettier",
Expand All @@ -18,8 +19,8 @@ export async function prettierFormat(targetDir: string, options: Options) {
throw new Error("There was a problem running the prettier in nextjs package");
}

if (options.extensions.includes("hardhat")) {
const hardhatPackagePath = path.join(targetDir, "/packages/hardhat");
if (options.extensions.includes(SOLIDITY_FRAMEWORKS.HARDHAT)) {
const hardhatPackagePath = path.join(targetDir, "packages", SOLIDITY_FRAMEWORKS.HARDHAT);
const hardhatPrettierConfig = path.join(hardhatPackagePath, ".prettierrc.json");
const hardhatResult = await execa("yarn", [
"prettier",
Expand All @@ -38,8 +39,8 @@ export async function prettierFormat(targetDir: string, options: Options) {
}
}

if (options.extensions.includes("foundry")) {
const foundryPackagePath = path.resolve(targetDir, "packages", "foundry");
if (options.extensions.includes(SOLIDITY_FRAMEWORKS.FOUNDRY)) {
const foundryPackagePath = path.resolve(targetDir, "packages", SOLIDITY_FRAMEWORKS.FOUNDRY);
const foundryResult = await execa("forge", ["fmt"], { cwd: foundryPackagePath });
if (foundryResult.failed) {
throw new Error("There was a problem running the forge fmt in the foundry package");
Expand Down

0 comments on commit 277e55c

Please sign in to comment.