From 6c7e9f6f3ac211454576e6e51cc5ff65718cd491 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Wed, 15 Apr 2026 22:39:59 -0400 Subject: refactor: migrate Effect call sites from Flock to EffectFlock (#22688) --- packages/shared/src/npm.ts | 8 +++++--- packages/shared/src/util/effect-flock.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/shared') diff --git a/packages/shared/src/npm.ts b/packages/shared/src/npm.ts index 994ec04da..8bd0cc468 100644 --- a/packages/shared/src/npm.ts +++ b/packages/shared/src/npm.ts @@ -5,7 +5,7 @@ import { Effect, Schema, Context, Layer, Option, FileSystem } from "effect" import { NodeFileSystem } from "@effect/platform-node" import { AppFileSystem } from "./filesystem" import { Global } from "./global" -import { Flock } from "./util/flock" +import { EffectFlock } from "./util/effect-flock" export namespace Npm { export class InstallFailedError extends Schema.TaggedErrorClass()("NpmInstallFailedError", { @@ -62,6 +62,7 @@ export namespace Npm { const afs = yield* AppFileSystem.Service const global = yield* Global.Service const fs = yield* FileSystem.FileSystem + const flock = yield* EffectFlock.Service const directory = (pkg: string) => path.join(global.cache, "packages", sanitize(pkg)) const outdated = Effect.fn("Npm.outdated")(function* (pkg: string, cachedVersion: string) { @@ -92,7 +93,7 @@ export namespace Npm { const add = Effect.fn("Npm.add")(function* (pkg: string) { const dir = directory(pkg) - yield* Flock.effect(`npm-install:${dir}`) + yield* flock.acquire(`npm-install:${dir}`) const arborist = new Arborist({ path: dir, @@ -133,7 +134,7 @@ export namespace Npm { }, Effect.scoped) const install = Effect.fn("Npm.install")(function* (dir: string) { - yield* Flock.effect(`npm-install:${dir}`) + yield* flock.acquire(`npm-install:${dir}`) const reify = Effect.fnUntraced(function* () { const arb = new Arborist({ @@ -240,6 +241,7 @@ export namespace Npm { ) export const defaultLayer = layer.pipe( + Layer.provide(EffectFlock.layer), Layer.provide(AppFileSystem.layer), Layer.provide(Global.layer), Layer.provide(NodeFileSystem.layer), diff --git a/packages/shared/src/util/effect-flock.ts b/packages/shared/src/util/effect-flock.ts index d728c0ef1..3e00afc9e 100644 --- a/packages/shared/src/util/effect-flock.ts +++ b/packages/shared/src/util/effect-flock.ts @@ -274,5 +274,5 @@ export namespace EffectFlock { }), ) - export const live = layer.pipe(Layer.provide(AppFileSystem.defaultLayer)) + export const defaultLayer = layer.pipe(Layer.provide(AppFileSystem.defaultLayer), Layer.provide(Global.layer)) } -- cgit v1.2.3