From 52a04306031ad9f15f57c7cb15c4586b8c08cad5 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 16 Oct 2016 22:52:39 +0300 Subject: [PATCH] cleanup console.logs --- test/mocks/newXhr.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/test/mocks/newXhr.js b/test/mocks/newXhr.js index f0a950df55..ba0e7fa7bd 100644 --- a/test/mocks/newXhr.js +++ b/test/mocks/newXhr.js @@ -1,25 +1,32 @@ // see https://gist.github.com/jfromaniello/4087861#gistcomment-1447029 // XMLHttpRequest to override. -//var xhrPath = '../node_modules/socket.io-client/node_modules/engine.io-client/node_modules/xmlhttprequest'; -var xhrPath = '../../node_modules/socket.io-client/node_modules/engine.io-client/node_modules/xmlhttprequest-ssl'; -var name; +/* globals console, require, module */ +var npm2Path = '../../node_modules/socket.io-client/node_modules/engine.io-client/node_modules/xmlhttprequest-ssl'; +var npm3Path = '../../node_modules/xmlhttprequest-ssl'; +var filePath; +var winston = require('winston'); + // Make initial call to require so module is cached. try { - require(xhrPath); - name = require.resolve(xhrPath); + require(npm2Path); + filePath = require.resolve(npm2Path); } catch (err) { - console.log('err1', err); + if (err) { + winston.info('Couldn\'t find ' + npm2Path); + } try { - require('../../node_modules/xmlhttprequest-ssl'); - name = require.resolve('xmlhttprequest-ssl'); + require(npm3Path); + filePath = require.resolve(npm3Path); } catch (err) { - console.log('err2', err); + if (err) { + winston.info('Couldn\'t find ' + npm3Path); + } } } -console.log(name); +winston.info('xmlhttprequest-ssl path: ' + filePath); // Get cached version. -var cachedXhr = require.cache[name]; +var cachedXhr = require.cache[filePath]; var stdXhr = cachedXhr.exports; // Callbacks exposes an object that callback functions can be added to. @@ -32,7 +39,7 @@ var newXhr = function () { callbacks[method].apply(this, arguments); } } -} +}; newXhr.XMLHttpRequest = newXhr;