mirror of https://github.com/status-im/metro.git
metro-bundler: fix e2e test
Reviewed By: jeanlauliac Differential Revision: D5310764 fbshipit-source-id: 275285086f92e7cb6a4e94afeb8ec535c663097c
This commit is contained in:
parent
5f0c5b231e
commit
01e1ff3b0a
|
@ -545,11 +545,7 @@ INSPECTOR_LEVELS[LOG_LEVELS.error] = 'error';
|
|||
|
||||
var INSPECTOR_FRAMES_TO_SKIP = __DEV__ ? 2 : 1;
|
||||
|
||||
function setupConsole(global) {
|
||||
if (!global.nativeLoggingHook) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (global.nativeLoggingHook) {
|
||||
function getNativeLogFunction(level) {
|
||||
return function () {
|
||||
var str = void 0;
|
||||
|
@ -633,11 +629,6 @@ function setupConsole(global) {
|
|||
}
|
||||
|
||||
var originalConsole = global.console;
|
||||
var descriptor = Object.getOwnPropertyDescriptor(global, 'console');
|
||||
if (descriptor) {
|
||||
Object.defineProperty(global, 'originalConsole', descriptor);
|
||||
}
|
||||
|
||||
global.console = {
|
||||
error: getNativeLogFunction(LOG_LEVELS.error),
|
||||
info: getNativeLogFunction(LOG_LEVELS.info),
|
||||
|
@ -649,6 +640,11 @@ function setupConsole(global) {
|
|||
};
|
||||
|
||||
if (__DEV__ && originalConsole) {
|
||||
var descriptor = Object.getOwnPropertyDescriptor(global, 'console');
|
||||
if (descriptor) {
|
||||
Object.defineProperty(global, 'originalConsole', descriptor);
|
||||
}
|
||||
|
||||
Object.keys(console).forEach(function (methodName) {
|
||||
var reactNativeMethod = console[methodName];
|
||||
if (originalConsole[methodName]) {
|
||||
|
@ -659,12 +655,17 @@ function setupConsole(global) {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = setupConsole;
|
||||
} else {
|
||||
setupConsole(global);
|
||||
} else if (!global.console) {
|
||||
function consoleLoggingStub() {};
|
||||
global.console = {
|
||||
error: consoleLoggingStub,
|
||||
info: consoleLoggingStub,
|
||||
log: consoleLoggingStub,
|
||||
warn: consoleLoggingStub,
|
||||
trace: consoleLoggingStub,
|
||||
debug: consoleLoggingStub,
|
||||
table: consoleLoggingStub
|
||||
};
|
||||
}
|
||||
})(typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this);
|
||||
(function(global) {
|
||||
|
|
Loading…
Reference in New Issue