diff --git a/lib/index.js b/lib/index.js index 7d71c7c..68bf50c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -35,11 +35,8 @@ var yellowLabTools = function(url, options) { if (options && typeof options.saveScreenshotFn === 'function') { debug('Now optimizing screenshot...'); - // Remove uneeded temp screenshot path - delete data.params.options.screenshot; - // TODO: temporarily set all screenshot sizes to 600px, until we find a solution - ScreenshotHandler.findAndOptimizeScreenshot(600) + ScreenshotHandler.findAndOptimizeScreenshot(data.params.options.screenshot, 600) .then(function(screenshotBuffer) { debug('Screenshot optimized, now saving...'); @@ -51,8 +48,8 @@ var yellowLabTools = function(url, options) { debug('Screenshot saved'); debug(response); - // Add the screenshot API url - data.screenshotUrl = '/api/results/' + data.runId + '/screenshot.jpg'; + // Remove uneeded temp screenshot path + delete data.params.options.screenshot; }) .catch(function(err) { diff --git a/lib/screenshotHandler.js b/lib/screenshotHandler.js index 7570857..3aab753 100644 --- a/lib/screenshotHandler.js +++ b/lib/screenshotHandler.js @@ -1,4 +1,4 @@ -var debug = require('debug')('ylt:screenshotHandler'); +var debug = require('debug')('ylt:screenshotHandlerAgent'); var Jimp = require('jimp'); var Q = require('q'); var fs = require('fs'); @@ -7,21 +7,15 @@ var path = require('path'); var screenshotHandler = function() { - var tmpFolderPath = 'tmp'; - var tmpFolderFullPath = path.join(__dirname, '..', tmpFolderPath); - var tmpFileName = 'temp-screenshot.png'; - var tmpFileFullPath = path.join(tmpFolderFullPath, tmpFileName); - - - this.findAndOptimizeScreenshot = function(width) { + this.findAndOptimizeScreenshot = function(tmpScreenshotPath, width) { var that = this; debug('Starting screenshot transformation'); - return this.openImage(tmpFileFullPath) + return this.openImage(tmpScreenshotPath) .then(function(image) { - that.deleteTmpFile(tmpFileFullPath); + that.deleteTmpFile(tmpScreenshotPath); return that.resizeImage(image, width); }) @@ -109,10 +103,6 @@ var screenshotHandler = function() { return deferred.promise; }; - - this.getTmpFileRelativePath = function() { - return tmpFolderPath + '/' + tmpFileName; - }; }; module.exports = new screenshotHandler(); diff --git a/package.json b/package.json index a68ddad..465de3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yellowlabtools", - "version": "2.1.0", + "version": "2.2.0", "description": "A tool that audits a webpage for performance and front-end quality issues", "license": "GPL-2.0", "author": { @@ -49,7 +49,7 @@ "md5": "2.2.1", "meow": "5.0.0", "parse-color": "1.0.0", - "phantomas": "2.2.0", + "phantomas": "2.8.0", "q": "1.5.1", "request": "2.88.0", "ttf2woff2": "4.0.1",