File tree 1 file changed +7
-4
lines changed
v-next/hardhat/src/internal/builtin-plugins/run
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
import type { NewTaskActionFunction } from "@nomicfoundation/hardhat-core/types/tasks" ;
2
2
3
- import path from "node:path" ;
3
+ import { isAbsolute , resolve } from "node:path" ;
4
+ import { pathToFileURL } from "node:url" ;
4
5
5
6
import {
6
7
HardhatError ,
@@ -22,9 +23,11 @@ export const runScriptWithHardhat: NewTaskActionFunction = async (
22
23
"Expected noCompile to be a boolean" ,
23
24
) ;
24
25
25
- const scriptPath = path . resolve ( process . cwd ( ) , script ) ;
26
+ const normalizedPath = isAbsolute ( script )
27
+ ? script
28
+ : resolve ( process . cwd ( ) , script ) ;
26
29
27
- if ( ! ( await exists ( scriptPath ) ) ) {
30
+ if ( ! ( await exists ( normalizedPath ) ) ) {
28
31
throw new HardhatError (
29
32
HardhatError . ERRORS . BUILTIN_TASKS . RUN_FILE_NOT_FOUND ,
30
33
{ script } ,
@@ -36,7 +39,7 @@ export const runScriptWithHardhat: NewTaskActionFunction = async (
36
39
}
37
40
38
41
try {
39
- await import ( scriptPath ) ;
42
+ await import ( pathToFileURL ( normalizedPath ) . href ) ;
40
43
} catch ( error ) {
41
44
if ( error instanceof Error ) {
42
45
throw new HardhatError (
You can’t perform that action at this time.
0 commit comments