Skip to content

Commit 1c5fdd0

Browse files
author
Guillaume Chau
committed
feat: hasPlugin matches router or vuex
1 parent ae1817a commit 1c5fdd0

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

packages/@vue/cli-service/lib/PluginAPI.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class PluginAPI {
4141
* @return {boolean}
4242
*/
4343
hasPlugin (id) {
44+
if (id === 'router') id = 'vue-router'
45+
if (['vue-router', 'vuex'].includes(id)) {
46+
const pkg = this.service.pkg
47+
return ((pkg.dependencies && pkg.dependencies[id]) || (pkg.devDependencies && pkg.devDependencies[id]))
48+
}
4449
return this.service.plugins.some(p => matchesPluginId(id, p.id))
4550
}
4651

packages/@vue/cli-ui/apollo-server/api/PluginApi.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ class PluginApi {
374374
* @param {string} id Plugin id or short id
375375
*/
376376
hasPlugin (id) {
377+
if (id === 'router') id = 'vue-router'
377378
if (['vue-router', 'vuex'].includes(id)) {
378379
const pkg = folders.readPackage(this.cwd, this.context, true)
379380
return ((pkg.dependencies && pkg.dependencies[id]) || (pkg.devDependencies && pkg.devDependencies[id]))

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ module.exports = class Generator {
213213
}
214214

215215
hasPlugin (_id) {
216+
if (_id === 'router') _id = 'vue-router'
217+
if (['vue-router', 'vuex'].includes(_id)) {
218+
const pkg = this.pkg
219+
return ((pkg.dependencies && pkg.dependencies[_id]) || (pkg.devDependencies && pkg.devDependencies[_id]))
220+
}
216221
return [
217222
...this.plugins.map(p => p.id),
218223
...Object.keys(this.pkg.devDependencies || {}),

0 commit comments

Comments
 (0)