@@ -33,7 +33,7 @@ import {
33
33
} from "../helpers/config-loading.js" ;
34
34
import { getHardhatRuntimeEnvironmentSingleton } from "../hre-singleton.js" ;
35
35
36
- export async function main ( cliArguments : string [ ] ) {
36
+ export async function main ( cliArguments : string [ ] , print = console . log ) {
37
37
const hreInitStart = performance . now ( ) ;
38
38
39
39
const usedCliArguments : boolean [ ] = new Array ( cliArguments . length ) . fill (
@@ -46,7 +46,7 @@ export async function main(cliArguments: string[]) {
46
46
) ;
47
47
48
48
if ( hardhatSpecialArgs . version ) {
49
- console . log ( "3.0.0" ) ;
49
+ print ( "3.0.0" ) ;
50
50
return ;
51
51
}
52
52
@@ -83,7 +83,7 @@ export async function main(cliArguments: string[]) {
83
83
) ;
84
84
85
85
const hreInitEnd = performance . now ( ) ;
86
- console . log ( "Time to initialize the HRE (ms):" , hreInitEnd - hreInitStart ) ;
86
+ print ( "Time to initialize the HRE (ms):" , hreInitEnd - hreInitStart ) ;
87
87
88
88
const taskParsingStart = performance . now ( ) ;
89
89
@@ -92,7 +92,7 @@ export async function main(cliArguments: string[]) {
92
92
if ( Array . isArray ( result ) ) {
93
93
if ( result . length === 0 ) {
94
94
// TODO: Print the global help
95
- console . log ( "Global help" ) ;
95
+ print ( "Global help" ) ;
96
96
return ;
97
97
}
98
98
@@ -104,32 +104,26 @@ export async function main(cliArguments: string[]) {
104
104
if ( hardhatSpecialArgs . help ) {
105
105
if ( task . isEmpty ) {
106
106
// TODO: Print information about its subtasks
107
- console . log ( "Info about subtasks" ) ;
107
+ print ( "Info about subtasks" ) ;
108
108
return ;
109
109
}
110
110
111
111
// TODO: Print the help message for this task
112
- console . log ( "Help message of the task" ) ;
112
+ print ( "Help message of the task" ) ;
113
113
return ;
114
114
}
115
115
116
116
const taskParsingEnd = performance . now ( ) ;
117
117
118
- console . log (
119
- "Time to parse the task (ms):" ,
120
- taskParsingEnd - taskParsingStart ,
121
- ) ;
118
+ print ( "Time to parse the task (ms):" , taskParsingEnd - taskParsingStart ) ;
122
119
123
120
const taskRunningStart = performance . now ( ) ;
124
121
125
122
await task . run ( taskArguments ) ;
126
123
127
124
const taskRunningEnd = performance . now ( ) ;
128
125
129
- console . log (
130
- "Time to run the task (ms):" ,
131
- taskRunningEnd - taskRunningStart ,
132
- ) ;
126
+ print ( "Time to run the task (ms):" , taskRunningEnd - taskRunningStart ) ;
133
127
} catch ( error ) {
134
128
process . exitCode = 1 ;
135
129
@@ -140,10 +134,10 @@ export async function main(cliArguments: string[]) {
140
134
141
135
// TODO: Print the errors nicely, especially `HardhatError`s.
142
136
143
- console . log ( "Error running the task:" , error . message ) ;
137
+ print ( "Error running the task:" , error . message ) ;
144
138
145
139
if ( hardhatSpecialArgs . showStackTraces ) {
146
- console . log ( "" ) ;
140
+ print ( "" ) ;
147
141
console . error ( error ) ;
148
142
}
149
143
}
0 commit comments