From 6ed353597733e906bacf6a9546983464134e4817 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Tue, 21 Feb 2023 14:12:00 -0800 Subject: [PATCH] fix: linked-strategy lifecycle missing bins (#6175) --- workspaces/arborist/lib/arborist/rebuild.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/workspaces/arborist/lib/arborist/rebuild.js b/workspaces/arborist/lib/arborist/rebuild.js index e8df69e328ce8..d502d5244bdc7 100644 --- a/workspaces/arborist/lib/arborist/rebuild.js +++ b/workspaces/arborist/lib/arborist/rebuild.js @@ -89,7 +89,6 @@ module.exports = cls => class Builder extends cls { const { depNodes, linkNodes, - storeNodes, } = this[_retrieveNodesByType](nodes) // build regular deps @@ -100,10 +99,6 @@ module.exports = cls => class Builder extends cls { this[_resetQueues]() await this[_build](linkNodes, { type: 'links' }) } - if (storeNodes.size) { - this[_resetQueues]() - await this[_build](storeNodes, { type: 'storelinks' }) - } process.emit('timeEnd', 'build') } @@ -146,6 +141,12 @@ module.exports = cls => class Builder extends cls { depNodes.add(node) } } + // Make sure that store linked nodes are processed last. + // We can't process store links separately or else lifecycle scripts on + // standard nodes might not have bin links yet. + for (const node of storeNodes) { + depNodes.add(node) + } // deduplicates link nodes and their targets, avoids // calling lifecycle scripts twice when running `npm rebuild` @@ -162,7 +163,6 @@ module.exports = cls => class Builder extends cls { return { depNodes, linkNodes, - storeNodes, } } @@ -330,10 +330,12 @@ module.exports = cls => class Builder extends cls { devOptional, package: pkg, location, + isStoreLink, } = node.target // skip any that we know we'll be deleting - if (this[_trashList].has(path)) { + // or storeLinks + if (this[_trashList].has(path) || isStoreLink) { return }