-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't throw when re-registering a plugin #4140
Conversation
throw new Error(`Illegal plugin name, "${name}", already exists.`); | ||
if (pluginExists(name)) { | ||
log.warn(`A plugin named "${name}" already exists. You may want to avoid re-registering plugins!`); | ||
} else if (Player.prototype.hasOwnProperty(name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an else if
because if a plugin exists, it will have a method on the Player.prototype
, but if the plugin does not exist and the name matches a Player.prototype
method, it's an actual player method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like a reasonable compromise.
throw new Error(`Illegal plugin name, "${name}", already exists.`); | ||
if (pluginExists(name)) { | ||
log.warn(`A plugin named "${name}" already exists. You may want to avoid re-registering plugins!`); | ||
} else if (Player.prototype.hasOwnProperty(name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like a reasonable compromise.
This should be rebased against master, will make tests run better. |
057ba55
to
10bb8c1
Compare
if (pluginExists(name) || Player.prototype.hasOwnProperty(name)) { | ||
throw new Error(`Illegal plugin name, "${name}", already exists.`); | ||
if (pluginExists(name)) { | ||
log.warn(`A plugin named "${name}" already exists. You may want to avoid re-registering plugins!`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@misteroneill when you get the chance, can you make another PR that silences this warning in the plugin tests?
Currently, if a plugin is re-registered, it will throw an error. On the face, this makes sense, but it comes with two issues:
Requirements Checklist