@@ -81,6 +81,22 @@ function notifyUser(plugin: Config, output: Output): void {
8181 }
8282}
8383
84+ export function normaliseTag ( jitPlugins : Record < string , string > , modifiedPlugins : Plugin [ ] , p : Interfaces . UserPlugin ) {
85+ // a not valid tag indicates that it's a dist-tag like 'latest'
86+ if ( ! valid ( p . tag ) ) return `${ p . name } @${ p . tag } `
87+
88+ if ( p . tag && valid ( p . tag ) && jitPlugins [ p . name ] && valid ( jitPlugins [ p . name ] ) && gt ( p . tag , jitPlugins [ p . name ] ) ) {
89+ // The user has installed a version of the JIT plugin that is newer than the one
90+ // specified by the root plugin's JIT configuration. In this case, we want to
91+ // keep the version installed by the user.
92+ return `${ p . name } @${ p . tag } `
93+ }
94+
95+ const tag = jitPlugins [ p . name ] ?? p . tag
96+ modifiedPlugins . push ( { ...p , tag} )
97+ return `${ p . name } @${ tag } `
98+ }
99+
84100export default class Plugins {
85101 public config : Interfaces . Config
86102 public readonly npm : NPM
@@ -379,21 +395,7 @@ export default class Plugins {
379395 const modifiedPlugins : Plugin [ ] = [ ]
380396 if ( npmPlugins . length > 0 ) {
381397 await this . npm . install (
382- npmPlugins . map ( ( p ) => {
383- // a not valid tag indicates that it's a dist-tag like 'latest'
384- if ( ! valid ( p . tag ) ) return `${ p . name } @${ p . tag } `
385-
386- if ( p . tag && valid ( p . tag ) && jitPlugins [ p . name ] && gt ( p . tag , jitPlugins [ p . name ] ) ) {
387- // The user has installed a version of the JIT plugin that is newer than the one
388- // specified by the root plugin's JIT configuration. In this case, we want to
389- // keep the version installed by the user.
390- return `${ p . name } @${ p . tag } `
391- }
392-
393- const tag = jitPlugins [ p . name ] ?? p . tag
394- modifiedPlugins . push ( { ...p , tag} )
395- return `${ p . name } @${ tag } `
396- } ) ,
398+ npmPlugins . map ( ( p ) => normaliseTag ( jitPlugins , modifiedPlugins , p ) ) ,
397399 { cwd : this . config . dataDir , logLevel : this . logLevel , prod : true } ,
398400 )
399401 }
0 commit comments