From fbdb43138ab8e682efb7668767465e7066d43b9f Mon Sep 17 00:00:00 2001 From: Gar Date: Thu, 10 Mar 2022 10:00:02 -0800 Subject: [PATCH] fix(rebuild): don't run lifecycle scripts twice on linked deps (#4529) --- workspaces/arborist/lib/arborist/rebuild.js | 27 ++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/workspaces/arborist/lib/arborist/rebuild.js b/workspaces/arborist/lib/arborist/rebuild.js index 09b4419f5b5dc..8b47904004a96 100644 --- a/workspaces/arborist/lib/arborist/rebuild.js +++ b/workspaces/arborist/lib/arborist/rebuild.js @@ -136,15 +136,19 @@ module.exports = cls => class Builder extends cls { process.emit('time', `build:${type}`) await this[_buildQueues](nodes) - if (!this[_ignoreScripts]) { - await this[_runScripts]('preinstall') - } - if (this[_binLinks] && type !== 'links') { - await this[_linkAllBins]() - } - - // links should also run prepare scripts and only link bins after that - if (type === 'links') { + // links should run prepare scripts and only link bins after that + if (type !== 'links') { + if (!this[_ignoreScripts]) { + await this[_runScripts]('preinstall') + } + if (this[_binLinks]) { + await this[_linkAllBins]() + } + if (!this[_ignoreScripts]) { + await this[_runScripts]('install') + await this[_runScripts]('postinstall') + } + } else { await this[_runScripts]('prepare') if (this[_binLinks]) { @@ -152,11 +156,6 @@ module.exports = cls => class Builder extends cls { } } - if (!this[_ignoreScripts]) { - await this[_runScripts]('install') - await this[_runScripts]('postinstall') - } - process.emit('timeEnd', `build:${type}`) }