Skip to content

Commit

Permalink
fix: avoid redefine property if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Jul 28, 2020
1 parent c1cd791 commit 4ac979c
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 134 deletions.
6 changes: 5 additions & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ class Strapi extends Hookable {

export default async function (ctx, inject) {
<%= JSON.stringify(options.entities) %>.forEach((entity) => {
Object.defineProperty(Strapi.prototype, `$${entity}`, {
const key = `$${entity}`
if (Strapi.prototype.hasOwnProperty(key)) {
return
}
Object.defineProperty(Strapi.prototype, key, {
get () {
const that = this
return {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"@babel/preset-env": "latest",
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"@nuxtjs/eslint-config": "latest",
"@nuxtjs/eslint-config": "^3.1.0",
"@nuxtjs/module-test-utils": "latest",
"babel-eslint": "latest",
"babel-jest": "latest",
"eslint": "latest",
"husky": "latest",
"jest": "latest",
"nuxt-edge": "latest",
"nuxt-edge": "^2.14.1-26598267.60f68638",
"standard-version": "latest"
},
"publishConfig": {
Expand Down
Loading

0 comments on commit 4ac979c

Please sign in to comment.