Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions workspaces/arborist/lib/arborist/load-actual.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,29 @@ module.exports = cls => class ActualLoader extends cls {

async #loadFSTree (node) {
const did = this.#actualTreeLoaded
if (!node.isLink && !did.has(node.target.realpath)) {
did.add(node.target.realpath)
await this.#loadFSChildren(node.target)

// For links, process the target node
// For regular nodes, process the node itself
const nodeToProcess = node.isLink ? node.target : node

// Skip if already processed or if nodeToProcess is undefined
if (!nodeToProcess || did.has(nodeToProcess.realpath)) {
return Promise.resolve()
}

did.add(nodeToProcess.realpath)
await this.#loadFSChildren(nodeToProcess)

// Process children if they exist
if (nodeToProcess.children.size > 0) {
return Promise.all(
[...node.target.children.entries()]
.filter(([, kid]) => !did.has(kid.realpath))
[...nodeToProcess.children.entries()]
.filter(([, kid]) => kid && !did.has(kid.realpath))
.map(([, kid]) => this.#loadFSTree(kid))
)
}

return Promise.resolve()
}

// create child nodes for all the entries in node_modules
Expand Down
6 changes: 1 addition & 5 deletions workspaces/arborist/test/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ const roots = [
'optofdev',
'other',
'root',
// This test flakes out on Apple Silicon
// https://github.com/npm/cli/pull/7411
process.platform === 'darwin' && process.arch === 'arm64'
? null
: 'selflink',
'selflink',
'symlinked-node-modules/example',
'workspace',
'workspace2',
Expand Down
Loading