@@ -90,9 +90,7 @@ module.exports = class Generator {
9090 this . pm = new PackageManager ( { context } )
9191 this . imports = { }
9292 this . rootOptions = { }
93- // we don't load the passed afterInvokes yet because we want to ignore them from other plugins
94- this . passedAfterInvokeCbs = afterInvokeCbs
95- this . afterInvokeCbs = [ ]
93+ this . afterInvokeCbs = afterInvokeCbs
9694 this . afterAnyInvokeCbs = afterAnyInvokeCbs
9795 this . configTransforms = { }
9896 this . defaultConfigTransforms = defaultConfigTransforms
@@ -124,7 +122,10 @@ module.exports = class Generator {
124122 const { rootOptions, invoking } = this
125123 const pluginIds = this . plugins . map ( p => p . id )
126124
127- // apply hooks from all plugins
125+ // avoid modifying the passed afterInvokes, because we want to ignore them from other plugins
126+ const passedAfterInvokeCbs = this . afterInvokeCbs
127+ this . afterInvokeCbs = [ ]
128+ // apply hooks from all plugins to collect 'afterAnyHooks'
128129 for ( const id of this . allPluginIds ) {
129130 const api = new GeneratorAPI ( id , this , { } , rootOptions )
130131 const pluginGenerator = loadModule ( `${ id } /generator` , this . context )
@@ -139,7 +140,7 @@ module.exports = class Generator {
139140 const afterAnyInvokeCbsFromPlugins = this . afterAnyInvokeCbs
140141
141142 // reset hooks
142- this . afterInvokeCbs = this . passedAfterInvokeCbs
143+ this . afterInvokeCbs = passedAfterInvokeCbs
143144 this . afterAnyInvokeCbs = [ ]
144145 this . postProcessFilesCbs = [ ]
145146
@@ -155,10 +156,9 @@ module.exports = class Generator {
155156 // because `afterAnyHooks` is already determined by the `allPluginIds` loop above
156157 await apply . hooks ( api , options , rootOptions , pluginIds )
157158 }
158-
159- // restore "any" hooks
160- this . afterAnyInvokeCbs = afterAnyInvokeCbsFromPlugins
161159 }
160+ // restore "any" hooks
161+ this . afterAnyInvokeCbs = afterAnyInvokeCbsFromPlugins
162162 }
163163
164164 async generate ( {
0 commit comments