From a15746d09375c8d29a16720a5f0d1355e9abf659 Mon Sep 17 00:00:00 2001 From: kchindam-infy Date: Thu, 8 May 2025 13:06:37 -0700 Subject: [PATCH] Working version --- .../arborist/lib/arborist/isolated-reifier.js | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/workspaces/arborist/lib/arborist/isolated-reifier.js b/workspaces/arborist/lib/arborist/isolated-reifier.js index a9a31dbf2e00a..d1e3ed23068bf 100644 --- a/workspaces/arborist/lib/arborist/isolated-reifier.js +++ b/workspaces/arborist/lib/arborist/isolated-reifier.js @@ -6,6 +6,7 @@ const pacote = require('pacote') const { join } = require('node:path') const { depth } = require('treeverse') const crypto = require('node:crypto') +const path = require('node:path') // cache complicated function results const memoize = (fn) => { @@ -96,6 +97,7 @@ module.exports = cls => class IsolatedReifier extends cls { result.localPath = node.path result.isWorkspace = true result.resolved = node.resolved + result.isLink = node.isLink || false await this.assignCommonProperties(node, result) } @@ -136,6 +138,7 @@ module.exports = cls => class IsolatedReifier extends cls { result.optional = node.optional result.resolved = node.resolved result.version = node.version + result.isLink = node.isLink || false } async assignCommonProperties (node, result) { @@ -317,11 +320,15 @@ module.exports = cls => class IsolatedReifier extends cls { hasShrinkwrap: false, inDepBundle: false, integrity: null, - isLink: false, + isLink: node.isLink || false, isRoot: false, isInStore: inStore, - path: join(proxiedIdealTree.root.localPath, location), - realpath: join(proxiedIdealTree.root.localPath, location), + path: node.isLink ? + join(proxiedIdealTree.root.localPath, node.locationPath || '', location) : + join(proxiedIdealTree.root.localPath, location), + realpath: node.isLink ? + join(proxiedIdealTree.root.localPath, node.locationPath || '', location) : + join(proxiedIdealTree.root.localPath, location), resolved: node.resolved, version: pkg.version, package: pkg, @@ -367,14 +374,19 @@ module.exports = cls => class IsolatedReifier extends cls { nmFolder = join('node_modules', '.store', key, 'node_modules') } else { from = node.isProjectRoot ? root : root.fsChildren.find(c => c.location === node.localLocation) - nmFolder = join(node.localLocation, 'node_modules') + nmFolder = node.isLink ? + join(proxiedIdealTree.root.localPath, node.localLocation || '', 'node_modules') : + join(node.localLocation, 'node_modules') } const processDeps = (dep, optional, external) => { optional = !!optional external = !!external - const location = join(nmFolder, dep.name) + const location = dep.isLink ? + join(proxiedIdealTree.root.localPath, dep.localLocation || '', 'node_modules', dep.name) : + join(nmFolder, dep.name) + const binNames = dep.package.bin && Object.keys(dep.package.bin) || [] const toKey = getKey(dep) @@ -388,7 +400,10 @@ module.exports = cls => class IsolatedReifier extends cls { // TODO: we should no-op is an edge has already been created with the same fromKey and toKey binNames.forEach(bn => { - target.binPaths.push(join(from.realpath, 'node_modules', '.bin', bn)) + const binPath = dep.isLink ? + join(proxiedIdealTree.root.localPath, from.realpath, 'node_modules', '.bin' , bn) : + join(from.realpath, 'node_modules', 'bin', bn) + target.binpaths.push(binpath) }) const link = {