Skip to content

Commit 045ea1d

Browse files
committed
fix for windows
1 parent 1d7dd29 commit 045ea1d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

v-next/hardhat/src/internal/builtin-plugins/run/runScriptWithHardhat.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { NewTaskActionFunction } from "@nomicfoundation/hardhat-core/types/tasks";
22

3-
import path from "node:path";
3+
import { isAbsolute, resolve } from "node:path";
4+
import { pathToFileURL } from "node:url";
45

56
import {
67
HardhatError,
@@ -22,9 +23,11 @@ export const runScriptWithHardhat: NewTaskActionFunction = async (
2223
"Expected noCompile to be a boolean",
2324
);
2425

25-
const scriptPath = path.resolve(process.cwd(), script);
26+
const normalizedPath = isAbsolute(script)
27+
? script
28+
: resolve(process.cwd(), script);
2629

27-
if (!(await exists(scriptPath))) {
30+
if (!(await exists(normalizedPath))) {
2831
throw new HardhatError(
2932
HardhatError.ERRORS.BUILTIN_TASKS.RUN_FILE_NOT_FOUND,
3033
{ script },
@@ -36,7 +39,7 @@ export const runScriptWithHardhat: NewTaskActionFunction = async (
3639
}
3740

3841
try {
39-
await import(scriptPath);
42+
await import(pathToFileURL(normalizedPath).href);
4043
} catch (error) {
4144
if (error instanceof Error) {
4245
throw new HardhatError(

0 commit comments

Comments
 (0)