@@ -25,7 +25,12 @@ export interface Interface {
2525 readonly add : ( pkg : string ) => Effect . Effect < EntryPoint , InstallFailedError | EffectFlock . LockError >
2626 readonly install : (
2727 dir : string ,
28- input ?: { add : string [ ] } ,
28+ input ?: {
29+ add : {
30+ name : string
31+ version ?: string
32+ } [ ]
33+ } ,
2934 ) => Effect . Effect < void , EffectFlock . LockError | InstallFailedError >
3035 readonly outdated : ( pkg : string , cachedVersion : string ) => Effect . Effect < boolean >
3136 readonly which : ( pkg : string ) => Effect . Effect < Option . Option < string > >
@@ -137,17 +142,18 @@ export const layer = Layer.effect(
137142 return resolveEntryPoint ( first . name , first . path )
138143 } , Effect . scoped )
139144
140- const install = Effect . fn ( "Npm.install" ) ( function * ( dir : string , input ?: { add : string [ ] } ) {
145+ const install : Interface [ "install" ] = Effect . fn ( "Npm.install" ) ( function * ( dir , input ) {
141146 const canWrite = yield * afs . access ( dir , { writable : true } ) . pipe (
142147 Effect . as ( true ) ,
143148 Effect . orElseSucceed ( ( ) => false ) ,
144149 )
145150 if ( ! canWrite ) return
146151
152+ const add = input ?. add . map ( ( pkg ) => [ pkg . name , pkg . version ] . filter ( Boolean ) . join ( "@" ) ) ?? [ ]
147153 yield * Effect . gen ( function * ( ) {
148154 const nodeModulesExists = yield * afs . existsSafe ( path . join ( dir , "node_modules" ) )
149155 if ( ! nodeModulesExists ) {
150- yield * reify ( { add : input ?. add , dir } )
156+ yield * reify ( { add, dir } )
151157 return
152158 }
153159 } ) . pipe ( Effect . withSpan ( "Npm.checkNodeModules" ) )
@@ -163,7 +169,7 @@ export const layer = Layer.effect(
163169 ...Object . keys ( pkgAny ?. devDependencies || { } ) ,
164170 ...Object . keys ( pkgAny ?. peerDependencies || { } ) ,
165171 ...Object . keys ( pkgAny ?. optionalDependencies || { } ) ,
166- ...( input ?. add || [ ] ) ,
172+ ...( input ?. add || [ ] ) . map ( ( pkg ) => pkg . name ) ,
167173 ] )
168174
169175 const root = lockAny ?. packages ?. [ "" ] || { }
@@ -176,7 +182,7 @@ export const layer = Layer.effect(
176182
177183 for ( const name of declared ) {
178184 if ( ! locked . has ( name ) ) {
179- yield * reify ( { dir, add : input ?. add } )
185+ yield * reify ( { dir, add } )
180186 return
181187 }
182188 }
0 commit comments