|
1 | | -import { execa, Options } from "execa"; |
| 1 | +import { execa } from "execa"; |
2 | 2 |
|
3 | 3 | export interface ForgeConfig { |
4 | 4 | // project |
@@ -76,69 +76,3 @@ export async function getRpcUrl(profile?: string): Promise<string> { |
76 | 76 | "http://127.0.0.1:8545" |
77 | 77 | ); |
78 | 78 | } |
79 | | - |
80 | | -/** |
81 | | - * Execute a forge command |
82 | | - * @param args The arguments to pass to forge |
83 | | - * @param options { profile?: The foundry profile to use; silent?: If true, nothing will be logged to the console } |
84 | | - */ |
85 | | -export async function forge( |
86 | | - args: string[], |
87 | | - options?: { profile?: string; silent?: boolean; env?: NodeJS.ProcessEnv; cwd?: string }, |
88 | | -): Promise<void> { |
89 | | - const execOptions = { |
90 | | - env: { FOUNDRY_PROFILE: options?.profile, ...options?.env }, |
91 | | - stdout: "inherit", |
92 | | - stderr: "pipe", |
93 | | - cwd: options?.cwd, |
94 | | - } satisfies Options; |
95 | | - |
96 | | - await (options?.silent ? execa("forge", args, execOptions) : execLog("forge", args, execOptions)); |
97 | | -} |
98 | | - |
99 | | -/** |
100 | | - * Execute a cast command |
101 | | - * @param args The arguments to pass to cast |
102 | | - * @returns Stdout of the command |
103 | | - */ |
104 | | -export async function cast(args: string[], options?: { profile?: string }): Promise<string> { |
105 | | - return execLog("cast", args, { |
106 | | - env: { FOUNDRY_PROFILE: options?.profile }, |
107 | | - }); |
108 | | -} |
109 | | - |
110 | | -/** |
111 | | - * Start an anvil chain |
112 | | - * @param args The arguments to pass to anvil |
113 | | - * @returns Stdout of the command |
114 | | - */ |
115 | | -export async function anvil(args: string[]): Promise<string> { |
116 | | - return execLog("anvil", args); |
117 | | -} |
118 | | - |
119 | | -/** |
120 | | - * Executes the given command, returns the stdout, and logs the command to the console. |
121 | | - * Throws an error if the command fails. |
122 | | - * @param command The command to execute |
123 | | - * @param args The arguments to pass to the command |
124 | | - * @returns The stdout of the command |
125 | | - */ |
126 | | -async function execLog(command: string, args: string[], options?: Options): Promise<string> { |
127 | | - const commandString = `${command} ${args.join(" ")}`; |
128 | | - try { |
129 | | - console.log(`running "${commandString}"`); |
130 | | - const { stdout } = await execa(command, args, { |
131 | | - ...options, |
132 | | - stdout: "pipe", |
133 | | - stderr: "pipe", |
134 | | - lines: false, |
135 | | - encoding: "utf8", |
136 | | - }); |
137 | | - return stdout; |
138 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
139 | | - } catch (error: any) { |
140 | | - let errorMessage = error?.stderr || error?.message || ""; |
141 | | - errorMessage += `\nError running "${commandString}"`; |
142 | | - throw new Error(errorMessage); |
143 | | - } |
144 | | -} |
0 commit comments