@@ -42,7 +42,6 @@ const _flagsSuspect = Symbol.for('flagsSuspect')
4242const _setWorkspaces = Symbol . for ( 'setWorkspaces' )
4343const _updateNames = Symbol . for ( 'updateNames' )
4444const _resolvedAdd = Symbol . for ( 'resolvedAdd' )
45- const _usePackageLock = Symbol . for ( 'usePackageLock' )
4645const _rpcache = Symbol . for ( 'realpathCache' )
4746const _stcache = Symbol . for ( 'statCache' )
4847
@@ -101,39 +100,28 @@ module.exports = cls => class IdealTreeBuilder extends cls {
101100 constructor ( options ) {
102101 super ( options )
103102
104- // normalize trailing slash
105- const registry = options . registry || 'https://registry.npmjs.org'
106- options . registry = this . registry = registry . replace ( / (?< ! \/ ) \/ + $ / , '' ) + '/'
107-
108103 const {
109104 follow = false ,
110105 installStrategy = 'hoisted' ,
111- idealTree = null ,
112- installLinks = false ,
113- legacyPeerDeps = false ,
114- packageLock = true ,
115106 strictPeerDeps = false ,
116- workspaces,
117107 global,
118108 } = options
119109
120110 this . #strictPeerDeps = ! ! strictPeerDeps
121111
122- this . idealTree = idealTree
123- this . installLinks = installLinks
124- this . legacyPeerDeps = legacyPeerDeps
125-
126- this [ _usePackageLock ] = packageLock
127112 this . #installStrategy = global ? 'shallow' : installStrategy
128113 this . #follow = ! ! follow
129114
130- if ( workspaces ?. length && global ) {
131- throw new Error ( 'Cannot operate on workspaces in global mode' )
132- }
133-
134115 this [ _updateAll ] = false
135116 this [ _updateNames ] = [ ]
136117 this [ _resolvedAdd ] = [ ]
118+
119+ // caches for cached realpath calls
120+ const cwd = process . cwd ( )
121+ // assume that the cwd is real enough for our purposes
122+ this [ _rpcache ] = new Map ( [ [ cwd , cwd ] ] )
123+ this [ _stcache ] = new Map ( )
124+ this [ _flagsSuspect ] = false
137125 }
138126
139127 get explicitRequests ( ) {
@@ -298,7 +286,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
298286 . then ( root => {
299287 if ( this . options . global ) {
300288 return root
301- } else if ( ! this [ _usePackageLock ] || this [ _updateAll ] ) {
289+ } else if ( ! this . options . usePackageLock || this [ _updateAll ] ) {
302290 return Shrinkwrap . reset ( {
303291 path : this . path ,
304292 lockfileVersion : this . options . lockfileVersion ,
@@ -1231,7 +1219,7 @@ This is a one-time fix-up, please be patient...
12311219 }
12321220 }
12331221
1234- #nodeFromSpec ( name , spec , parent , edge ) {
1222+ async #nodeFromSpec ( name , spec , parent , edge ) {
12351223 // pacote will slap integrity on its options, so we have to clone
12361224 // the object so it doesn't get mutated.
12371225 // Don't bother to load the manifest for link deps, because the target
@@ -1260,7 +1248,13 @@ This is a one-time fix-up, please be patient...
12601248 // Decide whether to link or copy the dependency
12611249 const shouldLink = ( isWorkspace || isProjectInternalFileSpec || ! installLinks ) && ! isTransitiveFileDep
12621250 if ( spec . type === 'directory' && shouldLink ) {
1263- return this . #linkFromSpec( name , spec , parent , edge )
1251+ const realpath = spec . fetchSpec
1252+ const { content : pkg } = await PackageJson . normalize ( realpath ) . catch ( ( ) => {
1253+ return { content : { } }
1254+ } )
1255+ const link = new Link ( { name, parent, realpath, pkg, installLinks, legacyPeerDeps } )
1256+ this . #linkNodes. add ( link )
1257+ return link
12641258 }
12651259
12661260 // if the spec matches a workspace name, then see if the workspace node will satisfy the edge. if it does, we return the workspace node to make sure it takes priority.
@@ -1301,17 +1295,6 @@ This is a one-time fix-up, please be patient...
13011295 } )
13021296 }
13031297
1304- async #linkFromSpec ( name , spec , parent ) {
1305- const realpath = spec . fetchSpec
1306- const { installLinks, legacyPeerDeps } = this
1307- const { content : pkg } = await PackageJson . normalize ( realpath ) . catch ( ( ) => {
1308- return { content : { } }
1309- } )
1310- const link = new Link ( { name, parent, realpath, pkg, installLinks, legacyPeerDeps } )
1311- this . #linkNodes. add ( link )
1312- return link
1313- }
1314-
13151298 // load all peer deps and meta-peer deps into the node's parent
13161299 // At the end of this, the node's peer-type outward edges are all
13171300 // resolved, and so are all of theirs, but other dep types are not.
@@ -1446,6 +1429,7 @@ This is a one-time fix-up, please be patient...
14461429 // and add it to the _depsQueue
14471430 //
14481431 // call buildDepStep if anything was added to the queue; otherwise, we're done
1432+ // XXX load-virtual also has a #resolveLinks, is there overlap?
14491433 #resolveLinks ( ) {
14501434 for ( const link of this . #linkNodes) {
14511435 this . #linkNodes. delete ( link )
0 commit comments