|
|
@@ -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
|