Skip to content

Commit 7da84f4

Browse files
committed
fix: findTask if task is not found
1 parent c112155 commit 7da84f4

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

.changeset/tough-jeans-own.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@uptask/core": patch
3+
---
4+
5+
Fixed findTask if task is not found

core/actions/__spec__/findTask.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ describe("findTask", () => {
3838
})
3939

4040
it("should throw error when no task matches predicate", () => {
41-
expect(() => findTask(tasks, task => task.name === "non-existent")).toThrow(
42-
"Task not found",
43-
)
41+
const foundTask = findTask(tasks, task => task.name === "non-existent")
42+
expect(foundTask).toBeUndefined()
4443
})
4544

4645
it("should handle empty tasks object", () => {
47-
expect(() => findTask({}, () => true)).toThrow("Task not found")
46+
const foundTask = findTask({}, () => true)
47+
expect(foundTask).toBeUndefined()
4848
})
4949
})

core/actions/findTask.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,5 @@ export function findTask<T extends Task>(
1212
.map(([_, task]) => task)
1313
.find(task => predicate(task))
1414

15-
if (!task) {
16-
throw new Error("Task not found")
17-
}
18-
1915
return task
2016
}

0 commit comments

Comments
 (0)