File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -295,9 +295,10 @@ function getTaskFromCliArguments(
295
295
}
296
296
297
297
if ( task === undefined ) {
298
- task = hre . tasks . getTask ( arg ) ;
299
- if ( task === undefined ) {
300
- return [ arg ] ;
298
+ try {
299
+ task = hre . tasks . getTask ( arg ) ;
300
+ } catch ( error ) {
301
+ return [ arg ] ; // No task found
301
302
}
302
303
} else {
303
304
const subtask = task . subtasks . get ( arg ) ;
Original file line number Diff line number Diff line change @@ -431,6 +431,17 @@ describe("main", function () {
431
431
} ) ;
432
432
} ) ;
433
433
434
+ it ( "should return the task id if not found" , function ( ) {
435
+ const command = "npx hardhat undefined-task" ;
436
+
437
+ const cliArguments = command . split ( " " ) . slice ( 2 ) ;
438
+ const usedCliArguments = [ false ] ;
439
+
440
+ const res = parseTaskAndArguments ( cliArguments , usedCliArguments , hre ) ;
441
+
442
+ assert . deepEqual ( res , [ "undefined-task" ] ) ;
443
+ } ) ;
444
+
434
445
it ( "should throw because the parameter is not defined" , function ( ) {
435
446
const command = "npx hardhat task0 --undefinedParam <value>" ;
436
447
You can’t perform that action at this time.
0 commit comments