Skip to content

Commit

Permalink
feat!: Dropped support for Node 18 and updated dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShogunPanda committed Oct 20, 2024
1 parent c39e67f commit fa33aec
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 41 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js LTS
- name: Use supported Node.js Version
uses: actions/setup-node@v3
with:
node-version: lts/*
node-version: 20.18.0*
- name: Restore cached dependencies
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .swcrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"jsc": {
"target": "es2022",
"target": "esnext",
"parser": {
"syntax": "typescript",
"tsx": false,
Expand Down
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { cowtech } from '@cowtech/eslint-config'

export default [
...cowtech,
{
languageOptions: {
parserOptions: {
project: './tsconfig.test.json'
}
}
}
]
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,32 @@
"build": "swc --strip-leading-paths --delete-dir-on-start -d dist src",
"postbuild": "concurrently npm:lint npm:typecheck",
"format": "prettier -w src test",
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx src test",
"lint": "eslint --cache",
"typecheck": "tsc -p . --emitDeclarationOnly",
"test": "c8 -c test/config/c8-local.json node --import tsx --test test/*.test.ts",
"test:ci": "c8 -c test/config/c8-ci.json node --import tsx --test-reporter=tap --test test/*.test.ts",
"test": "c8 -c test/config/c8-local.json node --env-file=test.env --test test/*.test.ts",
"test:ci": "c8 -c test/config/c8-ci.json node --env-file=test.env --test-reporter=tap --test test/*.test.ts",
"ci": "npm run build && npm run test:ci",
"prepublishOnly": "npm run ci",
"postpublish": "git push origin && git push origin -f --tags"
},
"dependencies": {
"image-size": "^1.1.1",
"undici": "^6.13.0"
"undici": "^6.20.1"
},
"devDependencies": {
"@cowtech/eslint-config": "^9.0.3",
"@swc/cli": "^0.3.12",
"@swc/core": "^1.4.13",
"@types/node": "^20.12.7",
"c8": "^9.1.0",
"chokidar": "^3.6.0",
"concurrently": "^8.2.2",
"eslint": "^8.57.0",
"prettier": "^3.2.5",
"tsx": "^4.7.2",
"typescript": "^5.4.5"
"@cowtech/eslint-config": "10.0.0",
"@swc-node/register": "^1.10.9",
"@swc/cli": "0.4.1-nightly.20240914",
"@swc/core": "^1.7.36",
"@types/node": "^22.7.7",
"c8": "^10.1.2",
"chokidar": "^4.0.1",
"concurrently": "^9.0.1",
"eslint": "^9.13.0",
"prettier": "^3.3.3",
"typescript": "^5.6.3"
},
"engines": {
"node": ">= 18.18.0"
"node": ">= 20.18.0"
}
}
2 changes: 1 addition & 1 deletion src/internals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export function handleError(error: FastImageError, url: string): Error {
case 'ECONNREFUSED':
message = 'Connection refused from the remote host.'
break
/* c8 ignore next */
/* c8 ignore next 2 */
case 'ETIMEDOUT':
case 'UND_ERR_HEADERS_TIMEOUT':
message = 'Connection to the remote host timed out.'
Expand Down
2 changes: 1 addition & 1 deletion src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export class FastImageStream extends Writable {
)
}

/* c8 ignore start */
_write(chunk: Buffer, _e: BufferEncoding, cb: (error?: Error | null) => void): void {
this.analyze(chunk)
cb()
}

/* c8 ignore start */
_writev(chunks: { chunk: Buffer }[], cb: (error?: Error | null) => void): void {
for (const { chunk } of chunks) {
this.analyze(chunk)
Expand Down
1 change: 1 addition & 0 deletions test.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NODE_OPTIONS=--import @swc-node/register/esm-register
2 changes: 0 additions & 2 deletions test/buffersAndStreams.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-floating-promises */

import { deepStrictEqual, rejects } from 'node:assert'
import { createReadStream, readFileSync } from 'node:fs'
import { test } from 'node:test'
Expand Down
2 changes: 0 additions & 2 deletions test/files.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-floating-promises */

import { deepStrictEqual, ifError } from 'node:assert'
import { chmodSync, existsSync, unlinkSync, writeFileSync } from 'node:fs'
import { dirname } from 'node:path'
Expand Down
2 changes: 0 additions & 2 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-floating-promises */

import { deepStrictEqual, ok, rejects } from 'node:assert'
import { test } from 'node:test'
import { info } from '../src/index.js'
Expand Down
2 changes: 0 additions & 2 deletions test/streams.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-floating-promises */

import { deepStrictEqual } from 'node:assert'
import { createReadStream } from 'node:fs'
import { test } from 'node:test'
Expand Down
14 changes: 10 additions & 4 deletions test/urls.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-floating-promises */

import { deepStrictEqual, ok, rejects } from 'node:assert'
import { readFileSync } from 'node:fs'
import { createServer as createHttpServer } from 'node:http'
Expand Down Expand Up @@ -52,10 +50,18 @@ test('fastimage.info', async () => {
})

await test('should handle connection timeouts', async () => {
const server = createServer(c => {})

server.listen({ port: 0 })

const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`

await rejects(
info('https://fakeimg.pl/1000x1000/', { timeout: 10 }),
new FastImageError('Connection to the remote host timed out.', 'NETWORK_ERROR', 'https://fakeimg.pl/1000x1000/')
info(url, { timeout: 10 }),
new FastImageError('Connection to the remote host timed out.', 'NETWORK_ERROR', url)
)

server.close()
})

await test('should handle connection failures', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2022",
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"jsx": "preserve",
Expand Down

0 comments on commit fa33aec

Please sign in to comment.