Skip to content

Commit a5e11ce

Browse files
committed
fix(lib): satisfy effect runtime state lint
1 parent 3ab1ade commit a5e11ce

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

packages/lib/src/usecases/project-runtime-state.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,22 @@ export const readProjectRuntimeState = (
143143
const fs = yield* _(FileSystem.FileSystem)
144144
const path = yield* _(Path.Path)
145145
const statePath = resolveProjectRuntimeStatePath(path, projectDir)
146-
const exists = yield* _(fs.exists(statePath))
147-
if (!exists) {
146+
const exists = yield* _(Effect.either(fs.exists(statePath)))
147+
const fileExists = Either.match(exists, {
148+
onLeft: () => false,
149+
onRight: (value) => value
150+
})
151+
if (!fileExists) {
148152
return emptyProjectRuntimeState()
149153
}
150154

151-
const contents = yield* _(fs.readFileString(statePath))
152-
const decoded = decodeProjectRuntimeStateFile(contents)
155+
const contents = yield* _(Effect.either(fs.readFileString(statePath)))
156+
const decoded = Either.match(contents, {
157+
onLeft: () => null,
158+
onRight: decodeProjectRuntimeStateFile
159+
})
153160
return decoded === null ? emptyProjectRuntimeState() : toRuntimeState(decoded)
154-
}).pipe(Effect.catchAll(() => Effect.succeed(emptyProjectRuntimeState())))
161+
})
155162

156163
// CHANGE: persist successful runtime launches into project-local `.orch/state`
157164
// WHY: DB-only project listing can still sort by latest launch time

0 commit comments

Comments
 (0)