Skip to content

Commit a15746d

Browse files
committed
Working version
1 parent 71bb817 commit a15746d

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

workspaces/arborist/lib/arborist/isolated-reifier.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const pacote = require('pacote')
66
const { join } = require('node:path')
77
const { depth } = require('treeverse')
88
const crypto = require('node:crypto')
9+
const path = require('node:path')
910

1011
// cache complicated function results
1112
const memoize = (fn) => {
@@ -96,6 +97,7 @@ module.exports = cls => class IsolatedReifier extends cls {
9697
result.localPath = node.path
9798
result.isWorkspace = true
9899
result.resolved = node.resolved
100+
result.isLink = node.isLink || false
99101
await this.assignCommonProperties(node, result)
100102
}
101103

@@ -136,6 +138,7 @@ module.exports = cls => class IsolatedReifier extends cls {
136138
result.optional = node.optional
137139
result.resolved = node.resolved
138140
result.version = node.version
141+
result.isLink = node.isLink || false
139142
}
140143

141144
async assignCommonProperties (node, result) {
@@ -317,11 +320,15 @@ module.exports = cls => class IsolatedReifier extends cls {
317320
hasShrinkwrap: false,
318321
inDepBundle: false,
319322
integrity: null,
320-
isLink: false,
323+
isLink: node.isLink || false,
321324
isRoot: false,
322325
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),
325332
resolved: node.resolved,
326333
version: pkg.version,
327334
package: pkg,
@@ -367,14 +374,19 @@ module.exports = cls => class IsolatedReifier extends cls {
367374
nmFolder = join('node_modules', '.store', key, 'node_modules')
368375
} else {
369376
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')
371380
}
372381

373382
const processDeps = (dep, optional, external) => {
374383
optional = !!optional
375384
external = !!external
376385

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+
378390
const binNames = dep.package.bin && Object.keys(dep.package.bin) || []
379391
const toKey = getKey(dep)
380392

@@ -388,7 +400,10 @@ module.exports = cls => class IsolatedReifier extends cls {
388400
// TODO: we should no-op is an edge has already been created with the same fromKey and toKey
389401

390402
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)
392407
})
393408

394409
const link = {

0 commit comments

Comments
 (0)