File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -871,13 +871,9 @@ module.exports = cls => class Reifier extends cls {
871871 return relative ( dir , resolve ( rootDir , overridePath ) )
872872 }
873873
874- // Fallback: derive the package name from node.resolved in a platform-agnostic way
874+ // Fallback: derive the file path from node.resolved in a platform-agnostic way
875875 const filePath = node . resolved . replace ( / ^ f i l e : / , '' )
876- // A node.package.name could be different than the folder name
877- const pathParts = filePath . split ( / [ \\ / ] / )
878- const packageName = pathParts [ pathParts . length - 1 ]
879-
880- return join ( '..' , packageName )
876+ return join ( filePath )
881877 }
882878
883879 #registryResolved ( resolved ) {
Original file line number Diff line number Diff line change @@ -3209,7 +3209,7 @@ t.test('root overrides with file: paths are visible to workspaces', async t => {
32093209 const path = t . testdir ( {
32103210 'package.json' : JSON . stringify ( {
32113211 name : 'root' ,
3212- workspaces : [ 'hello' ] ,
3212+ workspaces : [ 'hello' , 'nested/goodbye' ] ,
32133213 dependencies : { } ,
32143214 overrides : {
32153215 print : 'file:./print' ,
@@ -3224,6 +3224,17 @@ t.test('root overrides with file: paths are visible to workspaces', async t => {
32243224 } ,
32253225 } ) ,
32263226 } ,
3227+ nested : {
3228+ goodbye : {
3229+ 'package.json' : JSON . stringify ( {
3230+ name : 'second' ,
3231+ version : '1.0.0' ,
3232+ dependencies : {
3233+ print : '../print' ,
3234+ } ,
3235+ } ) ,
3236+ } ,
3237+ } ,
32273238 print : {
32283239 'package.json' : JSON . stringify ( {
32293240 name : 'print' ,
@@ -3237,6 +3248,7 @@ t.test('root overrides with file: paths are visible to workspaces', async t => {
32373248 await reify ( path )
32383249
32393250 const printSymlink = fs . readlinkSync ( resolve ( path , 'node_modules/print' ) )
3251+ const secondSymlink = fs . readlinkSync ( resolve ( path , 'node_modules/second' ) )
32403252
32413253 // Create a platform-agnostic way to compare symlink targets
32423254 const normalizeLinkTarget = target => {
@@ -3254,6 +3266,12 @@ t.test('root overrides with file: paths are visible to workspaces', async t => {
32543266 '../print' ,
32553267 'print symlink points to ../print (normalized for platform)'
32563268 )
3269+
3270+ t . equal (
3271+ normalizeLinkTarget ( secondSymlink ) ,
3272+ '../nested/goodbye' ,
3273+ 'print symlink points to ../nested/goodbye (normalized for platform)'
3274+ )
32573275} )
32583276
32593277t . test ( 'should preserve exact ranges, missing actual tree' , async ( t ) => {
You can’t perform that action at this time.
0 commit comments