@@ -124,6 +124,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
124124 globalStyle = false ,
125125 idealTree = null ,
126126 includeWorkspaceRoot = false ,
127+ installLinks = false ,
127128 legacyPeerDeps = false ,
128129 packageLock = true ,
129130 strictPeerDeps = false ,
@@ -135,6 +136,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
135136 this [ _strictPeerDeps ] = ! ! strictPeerDeps
136137
137138 this . idealTree = idealTree
139+ this . installLinks = installLinks
138140 this . legacyPeerDeps = legacyPeerDeps
139141
140142 this [ _usePackageLock ] = packageLock
@@ -410,6 +412,7 @@ Try using the package name instead, e.g:
410412 peer : false ,
411413 optional : false ,
412414 global : this [ _global ] ,
415+ installLinks : this . installLinks ,
413416 legacyPeerDeps : this . legacyPeerDeps ,
414417 loadOverrides : true ,
415418 } )
@@ -424,6 +427,7 @@ Try using the package name instead, e.g:
424427 peer : false ,
425428 optional : false ,
426429 global : this [ _global ] ,
430+ installLinks : this . installLinks ,
427431 legacyPeerDeps : this . legacyPeerDeps ,
428432 root,
429433 } )
@@ -992,6 +996,7 @@ This is a one-time fix-up, please be patient...
992996 preferDedupe : this [ _preferDedupe ] ,
993997 legacyBundling : this [ _legacyBundling ] ,
994998 strictPeerDeps : this [ _strictPeerDeps ] ,
999+ installLinks : this . installLinks ,
9951000 legacyPeerDeps : this . legacyPeerDeps ,
9961001 globalStyle : this [ _globalStyle ] ,
9971002 } ) )
@@ -1151,6 +1156,7 @@ This is a one-time fix-up, please be patient...
11511156 const vr = new Node ( {
11521157 path : node . realpath ,
11531158 sourceReference : node ,
1159+ installLinks : this . installLinks ,
11541160 legacyPeerDeps : this . legacyPeerDeps ,
11551161 overrides : node . overrides ,
11561162 } )
@@ -1268,17 +1274,18 @@ This is a one-time fix-up, please be patient...
12681274 // the object so it doesn't get mutated.
12691275 // Don't bother to load the manifest for link deps, because the target
12701276 // might be within another package that doesn't exist yet.
1271- const { legacyPeerDeps } = this
1277+ const { installLinks, legacyPeerDeps } = this
1278+ const isWorkspace = this . idealTree . workspaces && this . idealTree . workspaces . has ( spec . name )
12721279
1273- // spec is a directory, link it
1274- if ( spec . type === 'directory' ) {
1280+ // spec is a directory, link it unless installLinks is set or it's a workspace
1281+ if ( spec . type === 'directory' && ( isWorkspace || ! installLinks ) ) {
12751282 return this [ _linkFromSpec ] ( name , spec , parent , edge )
12761283 }
12771284
12781285 // if the spec matches a workspace name, then see if the workspace node will
12791286 // satisfy the edge. if it does, we return the workspace node to make sure it
12801287 // takes priority.
1281- if ( this . idealTree . workspaces && this . idealTree . workspaces . has ( spec . name ) ) {
1288+ if ( isWorkspace ) {
12821289 const existingNode = this . idealTree . edgesOut . get ( spec . name ) . to
12831290 if ( existingNode && existingNode . isWorkspace && existingNode . satisfies ( edge ) ) {
12841291 return edge . to
@@ -1288,7 +1295,7 @@ This is a one-time fix-up, please be patient...
12881295 // spec isn't a directory, and either isn't a workspace or the workspace we have
12891296 // doesn't satisfy the edge. try to fetch a manifest and build a node from that.
12901297 return this [ _fetchManifest ] ( spec )
1291- . then ( pkg => new Node ( { name, pkg, parent, legacyPeerDeps } ) , error => {
1298+ . then ( pkg => new Node ( { name, pkg, parent, installLinks , legacyPeerDeps } ) , error => {
12921299 error . requiredBy = edge . from . location || '.'
12931300
12941301 // failed to load the spec, either because of enotarget or
@@ -1298,6 +1305,7 @@ This is a one-time fix-up, please be patient...
12981305 name,
12991306 parent,
13001307 error,
1308+ installLinks,
13011309 legacyPeerDeps,
13021310 } )
13031311 this [ _loadFailures ] . add ( n )
@@ -1307,9 +1315,9 @@ This is a one-time fix-up, please be patient...
13071315
13081316 [ _linkFromSpec ] ( name , spec , parent , edge ) {
13091317 const realpath = spec . fetchSpec
1310- const { legacyPeerDeps } = this
1318+ const { installLinks , legacyPeerDeps } = this
13111319 return rpj ( realpath + '/package.json' ) . catch ( ( ) => ( { } ) ) . then ( pkg => {
1312- const link = new Link ( { name, parent, realpath, pkg, legacyPeerDeps } )
1320+ const link = new Link ( { name, parent, realpath, pkg, installLinks , legacyPeerDeps } )
13131321 this [ _linkNodes ] . add ( link )
13141322 return link
13151323 } )
0 commit comments