FEATURE: Improved deprecation warnings (#6722)

* FEATURE: Discourse.deprecate can report version

* Ember counterpart for deprecation
This commit is contained in:
Xiao Guan
2018-12-06 12:38:01 +01:00
committed by David Taylor
parent 1d649e147b
commit 7ec124fc89
3 changed files with 44 additions and 5 deletions

View File

@ -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
}