Skip to content

Commit

Permalink
simplify if conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherDedominici committed Nov 22, 2023
1 parent c87cc51 commit 7263a06
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/hardhat-core/src/internal/cli/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,7 @@ export async function complete({
}

// If there's no task or scope, we complete either tasks and scopes or params
if (
(taskName === undefined || tasks[taskName] === undefined) &&
(scopeName === undefined || scopes[scopeName] === undefined)
) {
if (taskDefinition === undefined && scopeDefinition === undefined) {
if (last.startsWith("-")) {
return coreParams.filter((param) => startsWithLast(param.name));
}
Expand All @@ -210,12 +207,8 @@ export async function complete({
}

// If there's a scope but not a task, we complete with the scopes'tasks
if (
taskName === undefined &&
scopeName !== undefined &&
scopes[scopeName] !== undefined
) {
return Object.values(scopes[scopeName].tasks)
if (taskDefinition === undefined && scopeDefinition !== undefined) {
return Object.values(scopes[scopeName!].tasks)
.filter((x) => !x.isSubtask)
.map((x) => ({
name: x.name,
Expand Down

0 comments on commit 7263a06

Please sign in to comment.