forked from scroll-tech/scroll
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
25 lines (20 loc) · 669 Bytes
/
utils.ts
File metadata and controls
25 lines (20 loc) · 669 Bytes
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
import * as fs from "fs";
import * as path from "path";
import editJsonFile from "edit-json-file";
const CONFIG_FILE_DIR = path.join(__dirname, "../", "deployments");
export function selectAddressFile(network: string) {
if (!fs.existsSync(CONFIG_FILE_DIR)) {
fs.mkdirSync(CONFIG_FILE_DIR, { recursive: true });
}
let filename: string;
if (["hardhat", "l1geth", "l2geth"].includes(network)) {
filename = path.join(CONFIG_FILE_DIR, `${network}.json`);
} else {
throw new Error(`network ${network} not supported yet`);
}
const addressFile = editJsonFile(filename, {
stringify_eol: true,
autosave: true,
});
return addressFile;
}