mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-03-14 13:11:10 -05:00
feat(ui): PluginApi validation: better errors
This commit is contained in:
@@ -13,6 +13,7 @@ class PluginApi {
|
||||
this.tasks = []
|
||||
this.clientAddons = []
|
||||
this.actions = new Map()
|
||||
this.pluginId = null
|
||||
}
|
||||
|
||||
describeConfig (options) {
|
||||
@@ -23,9 +24,9 @@ class PluginApi {
|
||||
logs.add({
|
||||
type: 'error',
|
||||
tag: 'PluginApi',
|
||||
message: 'describeConfig options are invalid\n' +
|
||||
e.message
|
||||
message: `(${this.pluginId || 'unknown plugin'}) 'describeConfig' options are invalid\n${e.message}`
|
||||
}, this.context)
|
||||
console.error(new Error(`Invalid options: ${e.message}`))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +38,9 @@ class PluginApi {
|
||||
logs.add({
|
||||
type: 'error',
|
||||
tag: 'PluginApi',
|
||||
message: 'describeTask options are invalid\n' +
|
||||
e.message
|
||||
message: `(${this.pluginId || 'unknown plugin'}) 'describeTask' options are invalid\n${e.message}`
|
||||
}, this.context)
|
||||
console.error(new Error(`Invalid options: ${e.message}`))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +58,9 @@ class PluginApi {
|
||||
logs.add({
|
||||
type: 'error',
|
||||
tag: 'PluginApi',
|
||||
message: 'addClientAddon options are invalid\n' +
|
||||
e.message
|
||||
message: `(${this.pluginId || 'unknown plugin'}) 'addClientAddon' options are invalid\n${e.message}`
|
||||
}, this.context)
|
||||
console.error(new Error(`Invalid options: ${e.message}`))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,9 @@ function resetPluginApi (context) {
|
||||
function runPluginApi (id, context, fileName = 'ui') {
|
||||
const module = loadModule(`${id}/${fileName}`, cwd.get(), true)
|
||||
if (module) {
|
||||
pluginApi.pluginId = id
|
||||
module(pluginApi)
|
||||
pluginApi.pluginId = null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user