| 78 | const flock = yield* EffectFlock.Service |
| 79 | const directory = (pkg: string) => path.join(global.cache, "packages", sanitize(pkg)) |
| 80 | const reify = (input: { dir: string; add?: string[] }) => |
| 81 | Effect.gen(function* () { |
| 82 | yield* flock.acquire(`npm-install:${input.dir}`) |
| 83 | const { Arborist } = yield* Effect.promise(() => import("@npmcli/arborist")) |
| 84 | const add = input.add ?? [] |
| 85 | const npmOptions = yield* NpmConfig.load(input.dir) |
| 86 | const arborist = new Arborist({ |
| 87 | ...npmOptions, |
| 88 | path: input.dir, |
| 89 | binLinks: true, |
| 90 | progress: false, |
| 91 | savePrefix: "", |
| 92 | ignoreScripts: true, |
| 93 | }) |
| 94 | return yield* Effect.tryPromise({ |
| 95 | try: () => |
| 96 | arborist.reify({ |
| 97 | ...npmOptions, |
| 98 | add, |
| 99 | save: true, |
| 100 | saveType: "prod", |
| 101 | }), |
| 102 | catch: (cause) => |
| 103 | new InstallFailedError({ |
| 104 | cause, |
| 105 | add, |
| 106 | dir: input.dir, |
| 107 | }), |
| 108 | }) as Effect.Effect<ArboristTree, InstallFailedError> |
| 109 | }).pipe( |
| 110 | Effect.withSpan("Npm.reify", { |
| 111 | attributes: input, |
| 112 | }), |
| 113 | ) |
| 114 | |
| 115 | const add = Effect.fn("Npm.add")(function* (pkg: string) { |
| 116 | const dir = directory(pkg) |