(cwd, jobPatch)
| 127 | } |
| 128 | |
| 129 | export function upsertJob(cwd, jobPatch) { |
| 130 | return updateState(cwd, (state) => { |
| 131 | const timestamp = nowIso(); |
| 132 | const existingIndex = state.jobs.findIndex((job) => job.id === jobPatch.id); |
| 133 | if (existingIndex === -1) { |
| 134 | state.jobs.unshift({ |
| 135 | createdAt: timestamp, |
| 136 | updatedAt: timestamp, |
| 137 | ...jobPatch |
| 138 | }); |
| 139 | return; |
| 140 | } |
| 141 | state.jobs[existingIndex] = { |
| 142 | ...state.jobs[existingIndex], |
| 143 | ...jobPatch, |
| 144 | updatedAt: timestamp |
| 145 | }; |
| 146 | }); |
| 147 | } |
| 148 | |
| 149 | export function listJobs(cwd) { |
| 150 | return loadState(cwd).jobs; |
no test coverage detected