Merge pull request #15 from zys-contribs/fix-emulate

fix path when no emulate
This commit is contained in:
Vladimir Carrer 2018-12-06 15:25:58 +01:00 committed by GitHub
commit ba97ec3105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -4,7 +4,7 @@ const puppeteer = require('puppeteer')
const devices = require('puppeteer/DeviceDescriptors')
const program = require('commander')
var urlvalue, emulate = "";
let urlvalue;
program
.option('--url, [url]', 'The url')
@ -40,7 +40,10 @@ console.log(fullPage);
const page = await browser.newPage()
const timestamp = new Date().getTime()
if (program.w && program.h) await page.setViewport({width: Number(program.w), height: Number(program.h)})
if (program.emulate) await page.emulate(devices[program.emulate]);
if (program.emulate)
await page.emulate(devices[program.emulate]);
else
program.emulate = '';
if (program.auth) {
const [username, password] = program.auth.split(';');
await page.authenticate({username:username, password:password});