@@ -5,7 +5,6 @@ const resolve = require('resolve')
5
5
const Generator = require ( './Generator' )
6
6
const { loadOptions } = require ( './options' )
7
7
const installDeps = require ( './util/installDeps' )
8
- const clearConsole = require ( './util/clearConsole' )
9
8
const {
10
9
log,
11
10
error,
@@ -30,26 +29,26 @@ async function invoke (pluginName, options) {
30
29
const findPlugin = deps => {
31
30
if ( ! deps ) return
32
31
let name
33
- if ( deps [ name = pluginName ] ||
34
- deps [ name = `@ vue/ cli-plugin-${ pluginName } ` ] ||
35
- deps [ name = `vue-cli-plugin- ${ pluginName } ` ] ) {
32
+ if ( deps [ name = `@vue/cli-plugin- ${ pluginName } ` ] ||
33
+ deps [ name = `vue- cli-plugin-${ pluginName } ` ] ||
34
+ deps [ name = pluginName ] ) {
36
35
return name
37
36
}
38
37
}
39
- const resolvedPluginName = (
40
- findPlugin ( pkg . devDependencies ) ||
41
- findPlugin ( pkg . dependencies )
42
- )
43
38
44
- if ( ! resolvedPluginName ) {
45
- error ( `Cannot resolve plugin ${ chalk . yellow ( pluginName ) } from package.json.` )
39
+ const id = findPlugin ( pkg . devDependencies ) || findPlugin ( pkg . dependencies )
40
+ if ( ! id ) {
41
+ error (
42
+ `Cannot resolve plugin ${ chalk . yellow ( pluginName ) } from package.json. ` +
43
+ `Did you forget to install it?`
44
+ )
46
45
process . exit ( 1 )
47
46
}
48
47
49
- const generatorURI = `${ resolvedPluginName } /generator`
48
+ const generatorURI = `${ id } /generator`
50
49
const generatorPath = resolve . sync ( generatorURI , { basedir : context } )
51
50
const plugin = {
52
- id : resolvedPluginName ,
51
+ id,
53
52
apply : require ( generatorPath ) ,
54
53
options
55
54
}
@@ -62,8 +61,8 @@ async function invoke (pluginName, options) {
62
61
createCompleteCbs
63
62
)
64
63
65
- clearConsole ( )
66
- logWithSpinner ( '🚀' , `Invoking generator for ${ resolvedPluginName } ...` )
64
+ log ( )
65
+ logWithSpinner ( '🚀' , `Invoking generator for ${ id } ...` )
67
66
await generator . generate ( )
68
67
69
68
const isTestOrDebug = process . env . VUE_CLI_TEST || process . env . VUE_CLI_DEBUG
@@ -89,7 +88,7 @@ async function invoke (pluginName, options) {
89
88
90
89
stopSpinner ( )
91
90
log ( )
92
- log ( ` Successfully invoked generator for plugin: ${ chalk . cyan ( resolvedPluginName ) } ` )
91
+ log ( ` Successfully invoked generator for plugin: ${ chalk . cyan ( id ) } ` )
93
92
log ( ` You should review and commit the changes.` )
94
93
log ( )
95
94
}
0 commit comments