feat: hasPlugin matches router or vuex

This commit is contained in:
Guillaume Chau
2018-07-28 01:32:49 +02:00
parent ae1817a769
commit 1c5fdd0184
3 changed files with 11 additions and 0 deletions
@@ -41,6 +41,11 @@ class PluginAPI {
* @return {boolean}
*/
hasPlugin (id) {
if (id === 'router') id = 'vue-router'
if (['vue-router', 'vuex'].includes(id)) {
const pkg = this.service.pkg
return ((pkg.dependencies && pkg.dependencies[id]) || (pkg.devDependencies && pkg.devDependencies[id]))
}
return this.service.plugins.some(p => matchesPluginId(id, p.id))
}
@@ -374,6 +374,7 @@ class PluginApi {
* @param {string} id Plugin id or short id
*/
hasPlugin (id) {
if (id === 'router') id = 'vue-router'
if (['vue-router', 'vuex'].includes(id)) {
const pkg = folders.readPackage(this.cwd, this.context, true)
return ((pkg.dependencies && pkg.dependencies[id]) || (pkg.devDependencies && pkg.devDependencies[id]))
+5
View File
@@ -213,6 +213,11 @@ module.exports = class Generator {
}
hasPlugin (_id) {
if (_id === 'router') _id = 'vue-router'
if (['vue-router', 'vuex'].includes(_id)) {
const pkg = this.pkg
return ((pkg.dependencies && pkg.dependencies[_id]) || (pkg.devDependencies && pkg.devDependencies[_id]))
}
return [
...this.plugins.map(p => p.id),
...Object.keys(this.pkg.devDependencies || {}),