fix plugins reinstalling too often

This commit is contained in:
Dax Raad
2026-04-18 20:02:24 -04:00
parent ad0545335a
commit f27eb8f09e
+12
View File
@@ -1,6 +1,7 @@
export * as Npm from "."
import path from "path"
import npa from "npm-package-arg"
import semver from "semver"
import { Effect, Schema, Context, Layer, Option, FileSystem } from "effect"
import { NodeFileSystem } from "@effect/platform-node"
@@ -135,6 +136,17 @@ export const layer = Layer.effect(
const add = Effect.fn("Npm.add")(function* (pkg: string) {
const dir = directory(pkg)
const name = (() => {
try {
return npa(pkg).name ?? pkg
} catch {
return pkg
}
})()
if (yield* afs.existsSafe(dir)) {
return resolveEntryPoint(name, path.join(dir, "node_modules", name))
}
const tree = yield* reify({ dir, add: [pkg] })
const first = tree.edgesOut.values().next().value?.to