From 4b24cd68ce5c04d21ae2cd85da39a0aef3c23332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sun, 10 Jan 2021 23:39:54 +0000 Subject: [PATCH] Debugging --- lib/tools/phantomas/phantomasWrapper.js | 9 ++++++++- lib/tools/redownload/redownload.js | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/tools/phantomas/phantomasWrapper.js b/lib/tools/phantomas/phantomasWrapper.js index c75c648..a4aa347 100644 --- a/lib/tools/phantomas/phantomasWrapper.js +++ b/lib/tools/phantomas/phantomasWrapper.js @@ -38,7 +38,6 @@ var PhantomasWrapper = function() { 'screenshot': task.options.screenshot || false, 'viewport': viewportOption, 'wait-for-network-idle': true, - //'wait-for-selector': task.options.waitForSelector, 'cookie': task.options.cookie, 'auth-user': task.options.authUser, 'auth-pass': task.options.authPass, @@ -58,6 +57,14 @@ var PhantomasWrapper = function() { options.proxy = task.options.proxy; } + var debugCmd = 'DEBUG=* node node_modules/phantomas/bin/phantomas.js --url ' + task.url; + Object.keys(options).forEach(function(key) { + if (key !== 'wait-for-network-idle' && options[key] !== null) { + debugCmd += ' --' + key + ' ' + options[key]; + } + }); + debug('If you want to run Phantomas alone for debugging purpose, this is the command: %s', debugCmd); + // It's time to launch the test!!! const promise = phantomas(task.url, options); diff --git a/lib/tools/redownload/redownload.js b/lib/tools/redownload/redownload.js index d9238d6..568ba2a 100644 --- a/lib/tools/redownload/redownload.js +++ b/lib/tools/redownload/redownload.js @@ -755,10 +755,18 @@ var Redownload = function() { function detectWordPress(requests) { // Check the first HTML file only var htmlRequest = requests.find(function(request) { - return request.isHTML && request.weightCheck.bodyBuffer; + return request.isHTML && request.weightCheck && request.weightCheck.bodyBuffer; }); - return htmlRequest && htmlRequest.weightCheck.bodyBuffer.indexOf('/wp-content/'); + debug('Checking if it is WordPress on file %s', htmlRequest.url); + + if (htmlRequest && htmlRequest.weightCheck.bodyBuffer.indexOf('/wp-content/') >= 0) { + debug('Response: yes.'); + return true; + } else { + debug('Response: no.'); + return false; + } }