Merge pull request #21 from vid-pas/12-width-only-full-height

12 allow for just width or height. If height, fix fullPage
This commit is contained in:
Vladimir Carrer 2018-12-08 12:31:29 +01:00 committed by GitHub
commit 95bc888f20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,7 +40,12 @@ console.log(program.fullPage);
const browser = await puppeteer.launch();
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.w || program.h) {
const newWidth = !program.w?600:program.w
const newHeight = !program.h?'0':program.h
if (program.h && !program.fullpage) program.fullPage = false;
await page.setViewport({width: Number(newWidth), height: Number(newHeight)})
}
if (program.emulate)
await page.emulate(devices[program.emulate]);
else