From: Wolfram Schneider Date: Mon, 13 Oct 2014 12:00:12 +0000 (+0200) Subject: check filename for .png extension X-Git-Tag: 1.0.0~237^2~1 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=f250e43f94ea55889cacd5986e2552b2199bfcb3;p=mkws-moved-to-github.git check filename for .png extension Without a correct file type extension, phantomjs will fail silently --- diff --git a/test/phantom/screenshot.js b/test/phantom/screenshot.js index 40f9937..8fea863 100644 --- a/test/phantom/screenshot.js +++ b/test/phantom/screenshot.js @@ -5,11 +5,23 @@ var url = system.args[1] || 'http://www.indexdata.com/'; var file_png = system.args[2] || 'indexdata.png'; var timeout = system.args[5] ? system.args[5] : 0.2; -if (system.args.length === 1) { +function usage (message) { + if (message) { + console.log(message + "\n"); + } console.log('Usage: screenshot.js '); phantom.exit(); } +if (system.args.length === 1) { + usage(); +} + +if (!file_png.match(/\.png$/)) { + usage("File name has no .png extension: '" + file_png + "'"); +} + + // page.zoomFactor = 1.0; page.viewportSize = { width: system.args[3] ? system.args[3] : 1200, @@ -28,3 +40,5 @@ page.open(url, function () { phantom.exit(); }, timeout * 1000); }); + +// EOF