Skip to content

Commit

Permalink
Updated sample to include missing “fs”, handle fs error and render “p…
Browse files Browse the repository at this point in the history
…ng” by default
  • Loading branch information
Johanndutoit committed May 7, 2017
1 parent 186c065 commit 4763a7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ As an example, to get you up and running quickly, here how to save a screenshot

```nodejs
// Gotta start somewhere !
const fs = require('fs');
const Browser = require('@passmarked/browser')
/**
Expand Down Expand Up @@ -145,12 +146,23 @@ client.load({
// render pdf
page.render({
format: 'pdf' // pdf, png or jpeg
format: 'png' // pdf, png or jpeg
}, function(err, buf) {
// check for error
if(err) {
// nope ...
console.log('file write failed :(');
// done
return page.close();
}
// write the buffer to file
fs.writeFile('output.pdf', buf, function() {
fs.writeFile('output.png', buf, function() {
// close the context
page.close();
Expand Down
2 changes: 0 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ module.exports = exports = function(options) {
// the entries
var entries = (result || {}).targetInfos || [];

console.dir(entries)

// close targets
for(var i = 0; i < entries.length; i++) {

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@passmarked/browser",
"version": "0.0.3",
"version": "0.0.4",
"description": "Easy to use remote browser control using the Chrome Dev Tools Debugging interface",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 4763a7e

Please sign in to comment.