refactor(cli): drop redundant explicit Effect.ensuring(store.dispose) (#25503)
This commit is contained in:
@@ -2,8 +2,6 @@ import { Effect } from "effect"
|
||||
import { Snapshot } from "../../../snapshot"
|
||||
import { effectCmd } from "../../effect-cmd"
|
||||
import { cmd } from "../cmd"
|
||||
import { InstanceRef } from "@/effect/instance-ref"
|
||||
import { InstanceStore } from "@/project/instance-store"
|
||||
|
||||
export const SnapshotCommand = cmd({
|
||||
command: "snapshot",
|
||||
@@ -16,13 +14,8 @@ const TrackCommand = effectCmd({
|
||||
command: "track",
|
||||
describe: "track current snapshot state",
|
||||
handler: Effect.fn("Cli.debug.snapshot.track")(function* () {
|
||||
const ctx = yield* InstanceRef
|
||||
if (!ctx) return
|
||||
const store = yield* InstanceStore.Service
|
||||
return yield* Effect.gen(function* () {
|
||||
const out = yield* Snapshot.Service.use((svc) => svc.track())
|
||||
console.log(out)
|
||||
}).pipe(Effect.ensuring(store.dispose(ctx)))
|
||||
const out = yield* Snapshot.Service.use((svc) => svc.track())
|
||||
console.log(out)
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -36,13 +29,8 @@ const PatchCommand = effectCmd({
|
||||
demandOption: true,
|
||||
}),
|
||||
handler: Effect.fn("Cli.debug.snapshot.patch")(function* (args) {
|
||||
const ctx = yield* InstanceRef
|
||||
if (!ctx) return
|
||||
const store = yield* InstanceStore.Service
|
||||
return yield* Effect.gen(function* () {
|
||||
const out = yield* Snapshot.Service.use((svc) => svc.patch(args.hash))
|
||||
console.log(out)
|
||||
}).pipe(Effect.ensuring(store.dispose(ctx)))
|
||||
const out = yield* Snapshot.Service.use((svc) => svc.patch(args.hash))
|
||||
console.log(out)
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -56,12 +44,7 @@ const DiffCommand = effectCmd({
|
||||
demandOption: true,
|
||||
}),
|
||||
handler: Effect.fn("Cli.debug.snapshot.diff")(function* (args) {
|
||||
const ctx = yield* InstanceRef
|
||||
if (!ctx) return
|
||||
const store = yield* InstanceStore.Service
|
||||
return yield* Effect.gen(function* () {
|
||||
const out = yield* Snapshot.Service.use((svc) => svc.diff(args.hash))
|
||||
console.log(out)
|
||||
}).pipe(Effect.ensuring(store.dispose(ctx)))
|
||||
const out = yield* Snapshot.Service.use((svc) => svc.diff(args.hash))
|
||||
console.log(out)
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user