Skip to content

Commit 1124b62

Browse files
committed
fix: vue add should not throw if plugin has no generator
The bug was introduced in #2337.
1 parent 30f7242 commit 1124b62

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const chalk = require('chalk')
22
const semver = require('semver')
33
const invoke = require('./invoke')
44
const inquirer = require('inquirer')
5-
const { loadModule } = require('@vue/cli-shared-utils')
5+
const { resolveModule, loadModule } = require('@vue/cli-shared-utils')
66

77
const PackageManager = require('./util/ProjectPackageManager')
88
const {
@@ -48,7 +48,12 @@ async function add (pluginName, options = {}, context = process.cwd()) {
4848
log(`${chalk.green('✔')} Successfully installed plugin: ${chalk.cyan(packageName)}`)
4949
log()
5050

51-
invoke(pluginName, options, context)
51+
const generatorPath = resolveModule(`${packageName}/generator`, context)
52+
if (generatorPath) {
53+
invoke(pluginName, options, context)
54+
} else {
55+
log(`Plugin ${packageName} does not have a generator to invoke`)
56+
}
5257
}
5358

5459
module.exports = (...args) => {

0 commit comments

Comments
 (0)