Skip to content

Commit 95ca69c

Browse files
pksunkarahaoqunjiang
authored andcommitted
fix: Make sure afterInvoke hook doesn't get run from other plugins (#4377)
1 parent e6a085e commit 95ca69c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/@vue/cli/lib/Generator.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ module.exports = class Generator {
8383
this.pm = new PackageManager({ context })
8484
this.imports = {}
8585
this.rootOptions = {}
86-
this.afterInvokeCbs = afterInvokeCbs
86+
// we don't load the passed afterInvokes yet because we want to ignore them from other plugins
87+
this.passedAfterInvokeCbs = afterInvokeCbs
88+
this.afterInvokeCbs = []
8789
this.afterAnyInvokeCbs = afterAnyInvokeCbs
8890
this.configTransforms = {}
8991
this.defaultConfigTransforms = defaultConfigTransforms
@@ -130,6 +132,7 @@ module.exports = class Generator {
130132
const afterAnyInvokeCbsFromPlugins = this.afterAnyInvokeCbs
131133

132134
// reset hooks
135+
this.afterInvokeCbs = this.passedAfterInvokeCbs
133136
this.afterAnyInvokeCbs = []
134137
this.postProcessFilesCbs = []
135138

@@ -142,7 +145,7 @@ module.exports = class Generator {
142145
if (apply.hooks) {
143146
// while we execute the entire `hooks` function,
144147
// only the `afterInvoke` hook is respected
145-
// because `afterAnyHooks` is already determined by the `allPluginIds` loop aboe
148+
// because `afterAnyHooks` is already determined by the `allPluginIds` loop above
146149
await apply.hooks(api, options, rootOptions, pluginIds)
147150
}
148151

0 commit comments

Comments
 (0)