( path: string, dependency: TaskDependency, context?: TaskNotesMutationContext )
| 2153 | } |
| 2154 | |
| 2155 | private async addDependency( |
| 2156 | path: string, |
| 2157 | dependency: TaskDependency, |
| 2158 | context?: TaskNotesMutationContext |
| 2159 | ): Promise<TaskInfo> { |
| 2160 | const task = await this.requireTask(path); |
| 2161 | const dependencies = task.blockedBy ?? []; |
| 2162 | const existingIndex = dependencies.findIndex( |
| 2163 | (candidate) => candidate.uid === dependency.uid |
| 2164 | ); |
| 2165 | const nextDependencies = |
| 2166 | existingIndex >= 0 |
| 2167 | ? dependencies.map((candidate, index) => |
| 2168 | index === existingIndex ? { ...dependency } : { ...candidate } |
| 2169 | ) |
| 2170 | : [...dependencies.map((candidate) => ({ ...candidate })), { ...dependency }]; |
| 2171 | |
| 2172 | return this.updateTask(task.path, { blockedBy: nextDependencies }, context); |
| 2173 | } |
| 2174 | |
| 2175 | private async removeDependency( |
| 2176 | path: string, |
no test coverage detected