Skip to content

Commit

Permalink
fix: vue add should not throw if plugin has no generator
Browse files Browse the repository at this point in the history
The bug was introduced in #2337.
  • Loading branch information
sodatea committed Nov 8, 2019
1 parent 30f7242 commit 1124b62
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/@vue/cli/lib/add.js
Expand Up @@ -2,7 +2,7 @@ const chalk = require('chalk')
const semver = require('semver')
const invoke = require('./invoke')
const inquirer = require('inquirer')
const { loadModule } = require('@vue/cli-shared-utils')
const { resolveModule, loadModule } = require('@vue/cli-shared-utils')

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

invoke(pluginName, options, context)
const generatorPath = resolveModule(`${packageName}/generator`, context)
if (generatorPath) {
invoke(pluginName, options, context)
} else {
log(`Plugin ${packageName} does not have a generator to invoke`)
}
}

module.exports = (...args) => {
Expand Down

0 comments on commit 1124b62

Please sign in to comment.