Skip to content

Commit

Permalink
More better README
Browse files Browse the repository at this point in the history
  • Loading branch information
udivankin authored and udi committed May 7, 2019
1 parent 687e088 commit 74fa6d6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,50 @@

<p>Tool based on <a href="https://github.com/GoogleChrome/puppeteer">puppeteer</a>.</p>

<h4>Installation</h4>
<h3>Installation and Usage:</h3>

```shell
npm i -g puppeteer-batch-screenshots
puppeteer-batch-screenshots config.json
```
<h3>Usage:</h3>

alternatively you can install it as a local dependency

```shell
puppeteer-batch-screenshots config.json
mkdir my-perfect-screenshoot-tool && cd my-perfect-screenshoot-tool
npm init -y
npm i puppeteer-batch-screenshots
node /node_modules/puppeteer-batch-screenshots/index.js config.json
```

<h3>Example config: </h3>

```js
[ // You can put multiple tasks here, each carrying custom settings
{
"width": 1440, // Viewport width, defaults to 1280
"height": 900, // Viewport height, defaults to 800
"fullPage": false, // Whether it shoud make screenshot of the whole page content
"emulate": "Nexus 4", // Device to emulate, see full list in https://github.com/GoogleChrome/puppeteer/blob/master/lib/DeviceDescriptors.js
"auth" : "username;password", // Auth username and password for HTTP basic auth
"waitFor": 500, // Number in ms to wait for, or alternatively CSS selector (e.g. ".footer") to wait to appear
"element": "#main", // CSS selector of element to take screenshot of
"routes": [ // Each task can have multiple routes to make screenshots of
// Viewport width, defaults to 1280
"width": 1440,
// Viewport height, defaults to 800
"height": 900,
// Whether it shoud make screenshot of the whole page content
"fullPage": false,
// Device to emulate, see full list at
// https://github.com/GoogleChrome/puppeteer/blob/master/lib/DeviceDescriptors.js
"emulate": "Nexus 4",
// Auth username and password for HTTP basic auth
"auth" : "username;password",
// Number in ms to wait for, or alternatively CSS selector (e.g. ".footer") to wait to appear
"waitFor": 500,
// CSS selector of element to take screenshot of
"element": "#main",
// Each task can have multiple routes
"routes": [
{
// Web page URL
"url": "http://example.com/1",
"output": "./screenshots/example-1-${new Date().toISOString()}.png" // Output field is being evaluated to enable template literals w/js code. Supported file extensions: PNG, JPEG/JPG and PDF
// Output field is being evaluated to enable template literals
// Supported file extensions: PNG, JPEG/JPG and PDF
"output": "./screenshots/example-1-${new Date().toISOString()}.png"
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const configPath = process.argv.pop();

if (!configPath) {
console.error('Error: config path is required');
if (!configPath || !fs.existsSync(path.resolve(configPath))) {
console.error('Error: config not provided');
process.exit(1);
}

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": "puppeteer-batch-screenshots",
"version": "1.0.2",
"version": "1.0.3",
"description": "Make screenshots of your websites in batch",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit 74fa6d6

Please sign in to comment.