mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FEATURE: Improved deprecation warnings (#6722)
* FEATURE: Discourse.deprecate can report version * Ember counterpart for deprecation
This commit is contained in:
@ -1,3 +1,15 @@
|
||||
export default function deprecated(msg) {
|
||||
console.warn(`DEPRECATION: ${msg}`); // eslint-disable-line no-console
|
||||
export default function deprecated(msg, opts = {}) {
|
||||
msg = ["Deprecation notice:", msg];
|
||||
if (opts.since) {
|
||||
msg.push(`(deprecated since Discourse ${opts.since})`);
|
||||
}
|
||||
if (opts.dropFrom) {
|
||||
msg.push(`(removal in Discourse ${opts.dropFrom})`);
|
||||
}
|
||||
msg = msg.join(" ");
|
||||
|
||||
if (opts.raiseError) {
|
||||
throw msg;
|
||||
}
|
||||
console.warn(msg); // eslint-disable-line no-console
|
||||
}
|
||||
|
Reference in New Issue
Block a user