Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 26, 2024
1 parent 2938f2a commit 219802c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 44 deletions.
52 changes: 27 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,44 +61,44 @@
"dependencies": {
"array-differ": "^4.0.0",
"array-uniq": "^3.0.0",
"capture-website": "^4.0.0",
"date-fns": "^2.30.0",
"capture-website": "^4.1.0",
"date-fns": "^3.6.0",
"filenamify": "^6.0.0",
"filenamify-url": "^3.0.0",
"filenamify-url": "^3.1.0",
"get-res": "^3.0.0",
"lodash.template": "^4.5.0",
"log-symbols": "^6.0.0",
"make-dir": "^4.0.0",
"p-map": "^6.0.0",
"make-dir": "^5.0.0",
"p-map": "^7.0.2",
"p-memoize": "^7.1.1",
"plur": "^5.1.0",
"type-fest": "^4.6.0",
"type-fest": "^4.23.0",
"unused-filename": "^4.0.1",
"viewport-list": "^5.1.1"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^5.0.0",
"@types/cookie": "^0.5.3",
"@types/get-res": "^3.0.2",
"@types/lodash.template": "^4.5.2",
"@types/node": "^20.8.10",
"@types/png.js": "^0.2.2",
"@types/sinon": "^17.0.0",
"@types/viewport-list": "^5.1.2",
"ava": "^5.3.1",
"cookie": "^0.5.0",
"@sindresorhus/tsconfig": "^6.0.0",
"@types/cookie": "^0.6.0",
"@types/get-res": "^3.0.3",
"@types/lodash.template": "^4.5.3",
"@types/node": "^20.14.12",
"@types/png.js": "^0.2.3",
"@types/sinon": "^17.0.3",
"@types/viewport-list": "^5.1.3",
"ava": "^6.1.3",
"cookie": "^0.6.0",
"del-cli": "^5.1.0",
"file-type": "^18.6.0",
"get-port": "^7.0.0",
"image-dimensions": "^2.1.0",
"nyc": "^15.1.0",
"file-type": "^19.3.0",
"get-port": "^7.1.0",
"image-dimensions": "^2.3.0",
"nyc": "^17.0.0",
"path-exists": "^5.0.0",
"pify": "^6.1.0",
"png.js": "^0.2.1",
"sinon": "^17.0.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"xo": "^0.56.0"
"sinon": "^18.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.4",
"xo": "^0.59.2"
},
"ava": {
"workerThreads": false,
Expand All @@ -119,7 +119,9 @@
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-call": "off",
"unicorn/prefer-event-target": "off"
"unicorn/prefer-event-target": "off",
"n/file-extension-in-import": "off",
"@typescript-eslint/no-unsafe-argument": "off"
}
},
"nyc": {
Expand Down
22 changes: 11 additions & 11 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import filenamify from 'filenamify';
import {unusedFilename} from 'unused-filename';
import arrayUniq from 'array-uniq';
import arrayDiffer from 'array-differ';
import dateFns from 'date-fns';
import {format as formatDate} from 'date-fns';
import getResolutions from 'get-res';
import logSymbols from 'log-symbols';
import makeDir from 'make-dir';
import {makeDirectory} from 'make-dir';
import viewportList from 'viewport-list';
import template from 'lodash.template';
import plur from 'plur';
Expand Down Expand Up @@ -257,10 +257,10 @@ export default class Pageres extends EventEmitter {
this.setMaxListeners(Number.POSITIVE_INFINITY);

this.#options = {...options};
this.#options.filename = this.#options.filename ?? '<%= url %>-<%= size %><%= crop %>';
this.#options.format = this.#options.format ?? 'png';
this.#options.incrementalName = this.#options.incrementalName ?? false;
this.#options.launchOptions = this.#options.launchOptions ?? {};
this.#options.filename ??= '<%= url %>-<%= size %><%= crop %>';
this.#options.format ??= 'png';
this.#options.incrementalName ??= false;
this.#options.launchOptions ??= {};
}

/**
Expand Down Expand Up @@ -452,9 +452,9 @@ export default class Pageres extends EventEmitter {

async #save(screenshots: Screenshot[]): Promise<void> {
await Promise.all(screenshots.map(async screenshot => {
await makeDir(this.destination());
const dest = path.join(this.destination(), screenshot.filename);
await fsPromises.writeFile(dest, screenshot);
await makeDirectory(this.destination());
const destination = path.join(this.destination(), screenshot.filename);
await fsPromises.writeFile(destination, screenshot);
}));
}

Expand All @@ -474,8 +474,8 @@ export default class Pageres extends EventEmitter {
const now = Date.now();
let filename = filenameTemplate({
crop: options.crop ? '-cropped' : '',
date: dateFns.format(now, 'yyyy-MM-dd'),
time: dateFns.format(now, 'HH-mm-ss'),
date: formatDate(now, 'yyyy-MM-dd'),
time: formatDate(now, 'HH-mm-ss'),
size,
width,
height,
Expand Down
4 changes: 2 additions & 2 deletions test/_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export type TestServer = {
protocol: string;
} & http.Server;

const baseCreateServer = (fn: http.RequestListener): (() => Promise<TestServer>) => async (): Promise<TestServer> => {
const baseCreateServer = (function_: http.RequestListener): (() => Promise<TestServer>) => async (): Promise<TestServer> => {
const port = await getPort();
const server = http.createServer(fn) as unknown as TestServer;
const server = http.createServer(function_) as unknown as TestServer;

server.host = host;
server.port = port;
Expand Down
2 changes: 1 addition & 1 deletion test/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function cookieTest(input: string | Cookie, t: ExecutionContext): Promise<

server.close();

const png = new PNG(screenshots[0]!);
const png = new PNG(screenshots[0]);
const {pixels} = await pify(png.parse.bind(png))();

t.is(pixels[0], 0);
Expand Down
9 changes: 4 additions & 5 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import {fileURLToPath} from 'node:url';
import path from 'node:path';
import test from 'ava';
import {imageDimensionsFromData} from 'image-dimensions';
import dateFns from 'date-fns';
import {format as formatDate} from 'date-fns';
import PNG from 'png.js';
import pify from 'pify';
import {pathExists} from 'path-exists';
import {stub as sinonStub} from 'sinon';
import {fileTypeFromBuffer} from 'file-type';
import Pageres, {type Screenshot} from '../source/index.js';
import type {TestServer} from './_server.js';
import {createServer} from './_server.js';
import {type TestServer, createServer} from './_server.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -113,7 +112,7 @@ test.serial('success message', async t => {
await pageres.run();
pageres.successMessage();
const [message] = stub.firstCall.args;
t.true(message.includes('Generated 3 screenshots from 1 url and 1 size'), message); // eslint-disable-line ava/assertion-arguments, @typescript-eslint/no-unsafe-argument
t.true(message.includes('Generated 3 screenshots from 1 url and 1 size'), message); // eslint-disable-line ava/assertion-arguments
stub.restore();
});

Expand Down Expand Up @@ -164,7 +163,7 @@ test('`filename` option', async t => {
.run();

t.is(screenshots.length, 1);
t.regex(screenshots[0].filename, new RegExp(`${dateFns.format(Date.now(), 'yyyy-MM-dd')} - \\d{2}-\\d{2}-\\d{2} - ${server.host}!${server.port}.png`));
t.regex(screenshots[0].filename, new RegExp(`${formatDate(Date.now(), 'yyyy-MM-dd')} - \\d{2}-\\d{2}-\\d{2} - ${server.host}!${server.port}.png`));
});

test('`selector` option', async t => {
Expand Down

0 comments on commit 219802c

Please sign in to comment.