@@ -90,9 +90,7 @@ module.exports = class Generator {
90
90
this . pm = new PackageManager ( { context } )
91
91
this . imports = { }
92
92
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
96
94
this . afterAnyInvokeCbs = afterAnyInvokeCbs
97
95
this . configTransforms = { }
98
96
this . defaultConfigTransforms = defaultConfigTransforms
@@ -124,7 +122,10 @@ module.exports = class Generator {
124
122
const { rootOptions, invoking } = this
125
123
const pluginIds = this . plugins . map ( p => p . id )
126
124
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'
128
129
for ( const id of this . allPluginIds ) {
129
130
const api = new GeneratorAPI ( id , this , { } , rootOptions )
130
131
const pluginGenerator = loadModule ( `${ id } /generator` , this . context )
@@ -139,7 +140,7 @@ module.exports = class Generator {
139
140
const afterAnyInvokeCbsFromPlugins = this . afterAnyInvokeCbs
140
141
141
142
// reset hooks
142
- this . afterInvokeCbs = this . passedAfterInvokeCbs
143
+ this . afterInvokeCbs = passedAfterInvokeCbs
143
144
this . afterAnyInvokeCbs = [ ]
144
145
this . postProcessFilesCbs = [ ]
145
146
@@ -155,10 +156,9 @@ module.exports = class Generator {
155
156
// because `afterAnyHooks` is already determined by the `allPluginIds` loop above
156
157
await apply . hooks ( api , options , rootOptions , pluginIds )
157
158
}
158
-
159
- // restore "any" hooks
160
- this . afterAnyInvokeCbs = afterAnyInvokeCbsFromPlugins
161
159
}
160
+ // restore "any" hooks
161
+ this . afterAnyInvokeCbs = afterAnyInvokeCbsFromPlugins
162
162
}
163
163
164
164
async generate ( {
0 commit comments