-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into localnet-authenticated-call
- Loading branch information
Showing
4 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { task, types } from "hardhat/config"; | ||
import fs from "fs"; | ||
import ansis from "ansis"; | ||
|
||
const LOCALNET_PID_FILE = "./localnet.pid"; | ||
|
||
const localnetCheck = async (args: any) => { | ||
await new Promise((resolve) => setTimeout(resolve, args.delay * 1000)); | ||
|
||
if (!fs.existsSync(LOCALNET_PID_FILE)) { | ||
console.log(ansis.red("Localnet is not running (PID file missing).")); | ||
process.exit(1); | ||
} | ||
|
||
const pid = fs.readFileSync(LOCALNET_PID_FILE, "utf-8").trim(); | ||
|
||
try { | ||
process.kill(Number(pid), 0); | ||
console.log(ansis.green(`Localnet is running (PID: ${pid}).`)); | ||
process.exit(0); | ||
} catch (err) { | ||
console.log(ansis.yellow(`Localnet process (PID: ${pid}) is not running.`)); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
export const localnetCheckTask = task( | ||
"localnet-check", | ||
"Check if localnet is running" | ||
) | ||
.addParam("delay", "Seconds to wait before checking localnet", 3, types.int) | ||
.setAction(localnetCheck); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { localnetTask } from "./localnet"; | ||
export { localnetStopTask } from "./stop"; | ||
export { localnetCheckTask } from "./check"; |