@@ -6,6 +6,7 @@ const pacote = require('pacote')
6
6
const { join } = require ( 'node:path' )
7
7
const { depth } = require ( 'treeverse' )
8
8
const crypto = require ( 'node:crypto' )
9
+ const path = require ( 'node:path' )
9
10
10
11
// cache complicated function results
11
12
const memoize = ( fn ) => {
@@ -96,6 +97,7 @@ module.exports = cls => class IsolatedReifier extends cls {
96
97
result . localPath = node . path
97
98
result . isWorkspace = true
98
99
result . resolved = node . resolved
100
+ result . isLink = node . isLink || false
99
101
await this . assignCommonProperties ( node , result )
100
102
}
101
103
@@ -136,6 +138,7 @@ module.exports = cls => class IsolatedReifier extends cls {
136
138
result . optional = node . optional
137
139
result . resolved = node . resolved
138
140
result . version = node . version
141
+ result . isLink = node . isLink || false
139
142
}
140
143
141
144
async assignCommonProperties ( node , result ) {
@@ -317,11 +320,15 @@ module.exports = cls => class IsolatedReifier extends cls {
317
320
hasShrinkwrap : false ,
318
321
inDepBundle : false ,
319
322
integrity : null ,
320
- isLink : false ,
323
+ isLink : node . isLink || false ,
321
324
isRoot : false ,
322
325
isInStore : inStore ,
323
- path : join ( proxiedIdealTree . root . localPath , location ) ,
324
- realpath : join ( proxiedIdealTree . root . localPath , location ) ,
326
+ path : node . isLink ?
327
+ join ( proxiedIdealTree . root . localPath , node . locationPath || '' , location ) :
328
+ join ( proxiedIdealTree . root . localPath , location ) ,
329
+ realpath : node . isLink ?
330
+ join ( proxiedIdealTree . root . localPath , node . locationPath || '' , location ) :
331
+ join ( proxiedIdealTree . root . localPath , location ) ,
325
332
resolved : node . resolved ,
326
333
version : pkg . version ,
327
334
package : pkg ,
@@ -367,14 +374,19 @@ module.exports = cls => class IsolatedReifier extends cls {
367
374
nmFolder = join ( 'node_modules' , '.store' , key , 'node_modules' )
368
375
} else {
369
376
from = node . isProjectRoot ? root : root . fsChildren . find ( c => c . location === node . localLocation )
370
- nmFolder = join ( node . localLocation , 'node_modules' )
377
+ nmFolder = node . isLink ?
378
+ join ( proxiedIdealTree . root . localPath , node . localLocation || '' , 'node_modules' ) :
379
+ join ( node . localLocation , 'node_modules' )
371
380
}
372
381
373
382
const processDeps = ( dep , optional , external ) => {
374
383
optional = ! ! optional
375
384
external = ! ! external
376
385
377
- const location = join ( nmFolder , dep . name )
386
+ const location = dep . isLink ?
387
+ join ( proxiedIdealTree . root . localPath , dep . localLocation || '' , 'node_modules' , dep . name ) :
388
+ join ( nmFolder , dep . name )
389
+
378
390
const binNames = dep . package . bin && Object . keys ( dep . package . bin ) || [ ]
379
391
const toKey = getKey ( dep )
380
392
@@ -388,7 +400,10 @@ module.exports = cls => class IsolatedReifier extends cls {
388
400
// TODO: we should no-op is an edge has already been created with the same fromKey and toKey
389
401
390
402
binNames . forEach ( bn => {
391
- target . binPaths . push ( join ( from . realpath , 'node_modules' , '.bin' , bn ) )
403
+ const binPath = dep . isLink ?
404
+ join ( proxiedIdealTree . root . localPath , from . realpath , 'node_modules' , '.bin' , bn ) :
405
+ join ( from . realpath , 'node_modules' , 'bin' , bn )
406
+ target . binpaths . push ( binpath )
392
407
} )
393
408
394
409
const link = {
0 commit comments