fix plugins reinstalling too often
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
export * as Npm from "."
|
export * as Npm from "."
|
||||||
|
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
import npa from "npm-package-arg"
|
||||||
import semver from "semver"
|
import semver from "semver"
|
||||||
import { Effect, Schema, Context, Layer, Option, FileSystem } from "effect"
|
import { Effect, Schema, Context, Layer, Option, FileSystem } from "effect"
|
||||||
import { NodeFileSystem } from "@effect/platform-node"
|
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 add = Effect.fn("Npm.add")(function* (pkg: string) {
|
||||||
const dir = directory(pkg)
|
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 tree = yield* reify({ dir, add: [pkg] })
|
||||||
const first = tree.edgesOut.values().next().value?.to
|
const first = tree.edgesOut.values().next().value?.to
|
||||||
|
|||||||
Reference in New Issue
Block a user