mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
ensure an env variable that handles deprecation messages
This commit is contained in:
committed by
Nacho Codoñer
parent
a993b78f86
commit
ac9257c0bd
@@ -1,3 +1,13 @@
|
||||
if (Meteor.isServer && Meteor.isDevelopment) {
|
||||
if (typeof __meteor_runtime_config__ === 'object') {
|
||||
var noDeprecations = process.env.METEOR_NO_DEPRECATIONS;
|
||||
if (noDeprecations === 'true' || noDeprecations === 'false') {
|
||||
noDeprecations = noDeprecations === 'true';
|
||||
}
|
||||
__meteor_runtime_config__.noDeprecations = noDeprecations;
|
||||
}
|
||||
}
|
||||
|
||||
function cleanStackTrace(stackTrace) {
|
||||
if (!stackTrace || typeof stackTrace !== 'string') return [];
|
||||
var lines = stackTrace.split('\n');
|
||||
@@ -28,6 +38,14 @@ Meteor.deprecate = function () {
|
||||
var stackStrace = cleanStackTrace(new Error().stack || '');
|
||||
var messages = Array.prototype.slice.call(arguments); // Convert arguments to array
|
||||
|
||||
if (typeof __meteor_runtime_config__.noDeprecations === 'string') {
|
||||
const noDeprecationPattern = new RegExp(__meteor_runtime_config__.noDeprecations);
|
||||
if (noDeprecationPattern.test(stackStrace)) {
|
||||
return;
|
||||
}
|
||||
} else if (typeof __meteor_runtime_config__.noDeprecations === 'boolean' && __meteor_runtime_config__.noDeprecations) {
|
||||
return;
|
||||
}
|
||||
if (stackStrace.length > 0) {
|
||||
messages.push('\n\n', 'Trace:', '\n', stackStrace);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user