diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index e6d719b6b3468..7ce22ff86b721 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -871,13 +871,9 @@ module.exports = cls => class Reifier extends cls { return relative(dir, resolve(rootDir, overridePath)) } - // Fallback: derive the package name from node.resolved in a platform-agnostic way + // Fallback: derive the file path from node.resolved in a platform-agnostic way const filePath = node.resolved.replace(/^file:/, '') - // A node.package.name could be different than the folder name - const pathParts = filePath.split(/[\\/]/) - const packageName = pathParts[pathParts.length - 1] - - return join('..', packageName) + return join(filePath) } #registryResolved (resolved) { diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index 29b0bc9e103c9..4f565ffc80860 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -3209,7 +3209,7 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { const path = t.testdir({ 'package.json': JSON.stringify({ name: 'root', - workspaces: ['hello'], + workspaces: ['hello', 'nested/goodbye'], dependencies: {}, overrides: { print: 'file:./print', @@ -3224,6 +3224,17 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { }, }), }, + nested: { + goodbye: { + 'package.json': JSON.stringify({ + name: 'second', + version: '1.0.0', + dependencies: { + print: '../print', + }, + }), + }, + }, print: { 'package.json': JSON.stringify({ name: 'print', @@ -3237,6 +3248,7 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { await reify(path) const printSymlink = fs.readlinkSync(resolve(path, 'node_modules/print')) + const secondSymlink = fs.readlinkSync(resolve(path, 'node_modules/second')) // Create a platform-agnostic way to compare symlink targets const normalizeLinkTarget = target => { @@ -3254,6 +3266,12 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { '../print', 'print symlink points to ../print (normalized for platform)' ) + + t.equal( + normalizeLinkTarget(secondSymlink), + '../nested/goodbye', + 'print symlink points to ../nested/goodbye (normalized for platform)' + ) }) t.test('should preserve exact ranges, missing actual tree', async (t) => { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy