Making ylt server work on both normal and AWS machines
This commit is contained in:
+3
-6
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
+2
-2
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user