From 99d161ba1b1c219f7a8cf85dd6734de045bd7b3a Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Wed, 29 Jan 2025 21:08:42 -0800 Subject: [PATCH] fix hardhat running on windows Solution was two-fold: 1. Run the hardhat.cmd script instead of hardhat 2. Use the absolute path to the script executable instead of relative to the working directory --- tests/integration/hardhatprocess.nim | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/integration/hardhatprocess.nim b/tests/integration/hardhatprocess.nim index d7652c2f..aeced386 100644 --- a/tests/integration/hardhatprocess.nim +++ b/tests/integration/hardhatprocess.nim @@ -36,7 +36,10 @@ method workingDir(node: HardhatProcess): string = return currentSourcePath() / ".." / ".." / ".." / "vendor" / "codex-contracts-eth" method executable(node: HardhatProcess): string = - return "node_modules" / ".bin" / "hardhat" + return "node_modules" / ".bin" / (when defined(windows): + "hardhat.cmd" + else: + "hardhat") method startedOutput(node: HardhatProcess): string = return "Started HTTP and WebSocket JSON-RPC server at" @@ -65,25 +68,26 @@ method start*( logScope: nodeName = node.name + var executable = "" try: - let binary = absolutePath(node.workingDir / node.executable) - if not fileExists(binary): - raiseAssert "cannot start hardhat, binary doesn't exist (looking for " & - &"{binary}). Try running `npm install` in {node.workingDir}." + executable = absolutePath(node.workingDir / node.executable) + if not fileExists(executable): + raiseAssert "cannot start hardhat, executable doesn't exist (looking for " & + &"{executable}). Try running `npm install` in {node.workingDir}." except CatchableError as parent: raiseAssert "failed build path to hardhat executable: " & parent.msg let poptions = node.processOptions + {AsyncProcessOption.StdErrToStdOut} trace "starting node", - args = node.arguments, - executable = node.executable, + args, + executable, workingDir = node.workingDir, processOptions = poptions try: node.process = await startProcess( - node.executable, + executable, node.workingDir, @["node"].concat(node.arguments), options = poptions,