Skip to content

Commit

Permalink
Implement getOutput() on browser.js
Browse files Browse the repository at this point in the history
  • Loading branch information
darron1217 committed Apr 16, 2018
1 parent 55671cf commit d33189d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bin/browser.js
Expand Up @@ -2,6 +2,15 @@ const puppeteer = require('puppeteer');

const request = JSON.parse(process.argv[2]);

const getOutput = (page, request) => {

if(request.action == 'evaluate') {
return page.evaluate(request.options.pageFunction);
}

return page[request.action](request.options);
}

const callChrome = async () => {
let browser;
let page;
Expand Down Expand Up @@ -73,11 +82,7 @@ const callChrome = async () => {
request.options.clip = await element.boundingBox();
}

if(request.action == 'evaluate') {
output = await page.evaluate(request.options.pageFunction);
} else {
output = await page[request.action](request.options);
}
output = await getOutput(page, request);

if (!request.options.path) {
console.log(output.toString('base64'));
Expand Down

0 comments on commit d33189d

Please sign in to comment.