Socket
Socket
Sign inDemoInstall

capture-website

Package Overview
Dependencies
46
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.2 to 0.2.0

29

index.js

@@ -61,2 +61,3 @@ 'use strict';

debug: false,
launchOptions: {},
_keepAlive: false,

@@ -92,6 +93,7 @@ ...options

const launchOptions = {};
const launchOptions = {...options.launchOptions};
if (options.debug) {
launchOptions.headless = !options.debug;
launchOptions.headless = false;
launchOptions.slowMo = 100;
}

@@ -102,2 +104,18 @@

if (options.debug) {
page.on('console', message => {
let {url, lineNumber, columnNumber} = message.location();
lineNumber = lineNumber ? `:${lineNumber}` : '';
columnNumber = columnNumber ? `:${columnNumber}` : '';
const location = url ? ` (${url}${lineNumber}${columnNumber})` : '';
console.log(`\nPage log:${location}\n${message.text()}\n`);
});
page.on('pageerror', error => {
console.log('\nPage error:', error, '\n');
});
// TODO: Add more events from https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#event-requestfailed
}
if (options.authentication) {

@@ -205,5 +223,8 @@ await page.authenticate(options.authentication);

module.exports.file = async (url, filePath, options) => {
module.exports.file = async (url, filePath, options = {}) => {
const screenshot = await captureWebsite(url, options);
await writeFile(filePath, screenshot, {flag: 'wx'});
await writeFile(filePath, screenshot, {
flag: options.overwrite ? 'w' : 'wx'
});
};

@@ -210,0 +231,0 @@

2

package.json
{
"name": "capture-website",
"version": "0.1.2",
"version": "0.2.0",
"description": "Capture screenshots of websites",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -352,4 +352,24 @@ # capture-website [![Build Status](https://travis-ci.com/sindresorhus/capture-website.svg?branch=master)](https://travis-ci.com/sindresorhus/capture-website)

Show the browser window so you can see what it's doing.
Show the browser window so you can see what it's doing, redirect page console output to the terminal, and slow down each Puppeteer operation.
Note: This overrides `launchOptions` with `{headless: false, slowMo: 100}`.
##### launchOptions
Type: `Object`<br>
Default: `{}`
Options passed to [`puppeteer.launch()`](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
Note: Some of the launch options are overridden by the `debug` option.
##### overwrite
Type: `boolean`<br>
Default: `false`
Overwrite the destination file if it exists instead of throwing an error.
*This option applies only to `captureWebsite.file()`.*
### captureWebsite.devices

@@ -356,0 +376,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc