-
Notifications
You must be signed in to change notification settings - Fork 2
/
fork.ts
40 lines (28 loc) · 841 Bytes
/
fork.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as dotenv from 'dotenv';
dotenv.config();
const forkChain = async () => {
const { spawn } = await import("child_process");
const RPC = process.env['RPC']!
let params = ["-f",RPC]
let blockNumber;
if (blockNumber) {
params.push(`--fork-block-number=${blockNumber}`)
}
/// You can add as much customs params as wanted
const childProcess = spawn('anvil',params, {
stdio: "inherit",
});
childProcess.once("close", (status) => {
childProcess.removeAllListeners("error");
if (status === 0) {
console.log('ok')
} else {
console.log('error')
}
});
childProcess.once("error", (_status) => {
childProcess.removeAllListeners("close");
console.log('error')
});
}
forkChain()