Skip to content

Commit

Permalink
Require Node.js 14
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 11, 2022
1 parent b109f45 commit 25d19de
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 18
- 16
- 14
- 12
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
5 changes: 3 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
import {Buffer} from 'node:buffer';
import {
LaunchOptions as PuppeteerLaunchOptions,
BrowserLaunchArgumentOptions,
BrowserConnectOptions,
Page,
Browser,
EvaluateFn,
EvaluateFunc,
Protocol,
Product,
BoundingBox,
Expand Down Expand Up @@ -240,7 +241,7 @@ export interface Options {
This can be useful for [altering the JavaScript environment](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pageevaluateonnewdocumentpagefunction-args). For example, you could define a global method on the `window`, overwrite `navigator.languages` to change the language presented by the browser, or mock `Math.random` to return a fixed value.
*/
readonly preloadFunction?: EvaluateFn;
readonly preloadFunction?: EvaluateFunc<unknown[]>;

/**
Inject [JavaScript modules](https://developers.google.com/web/fundamentals/primers/modules) into the page.
Expand Down
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12.20"
"node": ">=14.16"
},
"scripts": {
"//test": "xo && ava",
"test": "xo && ava && tsd"
},
"files": [
Expand All @@ -36,34 +35,34 @@
"chromium",
"image",
"png",
"jpg"
"jpg",
"jpeg"
],
"dependencies": {
"@cliqz/adblocker-puppeteer": "^1.23.2",
"@cliqz/adblocker-puppeteer": "^1.23.8",
"file-url": "^4.0.0",
"puppeteer": "^13.1.1",
"node-fetch": "^3.1.0",
"puppeteer": "^16.1.0",
"node-fetch": "^3.2.10",
"tough-cookie": "^4.0.0"
},
"devDependencies": {
"ava": "^4.0.1",
"ava": "^4.3.1",
"create-test-server": "^3.0.1",
"delay": "^5.0.0",
"image-size": "^1.0.1",
"image-size": "^1.0.2",
"is-jpg": "^3.0.0",
"is-png": "^3.0.1",
"pify": "^5.0.0",
"pify": "^6.0.0",
"png-js": "^1.0.0",
"tempy": "^2.0.0",
"tsd": "^0.19.1",
"typescript": "^4.5.5",
"xo": "^0.47.0"
"tempy": "^3.0.0",
"tsd": "^0.22.0",
"xo": "^0.51.0"
},
"tsd": {
"compilerOptions": {
"lib": [
"dom",
"es2019"
"es2020"
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ See [capture-website-cli](https://github.com/sindresorhus/capture-website-cli) f

## Install

```
$ npm install capture-website
```sh
npm install capture-website
```

Note to Linux users: If you get a sandbox-related error, you need to enable [system sandboxing](#im-getting-a-sandbox-related-error).
Expand Down
18 changes: 9 additions & 9 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global document, window */
/* global document */
import {Buffer} from 'node:buffer';
import fs from 'node:fs';
import test from 'ava';
Expand All @@ -8,7 +8,7 @@ import isPng from 'is-png';
import pify from 'pify';
import PNG from 'png-js';
import createTestServer from 'create-test-server';
import tempy from 'tempy';
import {temporaryFile} from 'tempy';
import delay from 'delay';
import toughCookie from 'tough-cookie';
import fileUrl from 'file-url';
Expand Down Expand Up @@ -92,7 +92,7 @@ test('capture screenshot - from HTML content', async t => {
});

test('captureWebsite.file()', async t => {
const filePath = tempy.file();
const filePath = temporaryFile();

await captureWebsite.file(server.url, filePath, {
width: 100,
Expand Down Expand Up @@ -690,7 +690,7 @@ test('`authentication` option', async t => {
});

test('`overwrite` option', async t => {
const filePath = tempy.file();
const filePath = temporaryFile();

await t.notThrowsAsync(async () => {
await captureWebsite.file(server.url, filePath, {
Expand Down Expand Up @@ -855,15 +855,15 @@ test('`inset` option', async t => {
});
});

test('`preloadFunction` option', async t => {
test.failing('`preloadFunction` option', async t => {
const server = await createTestServer();

server.get('/', async (request, response) => {
response.end(`
<body style="margin: 0;">
<div style="background-color: black; width: 100px; height: 100px;"></div>
<script>
window.toRed();
<script async>
globalThis.toRed();
</script>
</body>
`);
Expand All @@ -872,8 +872,8 @@ test('`preloadFunction` option', async t => {
const pixels = await getPngPixels(await instance(server.url, {
width: 100,
height: 100,
preloadFunction: () => {
window.toRed = () => {
preloadFunction() {
globalThis.toRed = () => {
document.querySelector('div').style.backgroundColor = 'red';
};
},
Expand Down

0 comments on commit 25d19de

Please sign in to comment.