Skip to content

Commit dcfd9ce

Browse files
committed
feat!: Dropped support for Node 20.
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
1 parent d9347a6 commit dcfd9ce

File tree

13 files changed

+54
-70
lines changed

13 files changed

+54
-70
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ name: CI
33
on: [push, pull_request, workflow_dispatch]
44
jobs:
55
ci:
6-
runs-on: ubuntu-latest
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
os: [ubuntu-latest, windows-latest]
10+
node-version: [22, 24, 25]
11+
runs-on: ${{ matrix.os }}
712
steps:
813
- name: Checkout
9-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1015
- name: Use supported Node.js Version
11-
uses: actions/setup-node@v3
16+
uses: actions/setup-node@v4
1217
with:
13-
node-version: 20.18.0
18+
node-version: ${{ matrix.node-version }}
1419
- name: Restore cached dependencies
1520
uses: actions/cache@v3
1621
with:

.swcrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

generate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { writeFile } from 'node:fs/promises'
22
import { STATUS_CODES } from 'node:http'
33
import { createRequire } from 'node:module'
44
import { format } from 'prettier'
5-
import { lowerFirst, upperFirst } from './src/utils.js'
5+
import { lowerFirst, upperFirst } from './src/utils.ts'
66

77
function buildError(code: number, description: string, identifier: string, error: string, additional: object): string {
88
const definition = {
@@ -197,8 +197,8 @@ async function main(): Promise<void> {
197197
'src/errors.ts',
198198
await format(
199199
`
200-
import { HttpError } from './base.js'
201-
import { type GenericObject } from './utils.js'
200+
import { HttpError } from './base.ts'
201+
import { type GenericObject } from './utils.ts'
202202
203203
${classes.join('\n\n')}
204204
`.trim(),

package.json

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,29 @@
2929
"exports": "./dist/index.js",
3030
"types": "./dist/index.d.ts",
3131
"scripts": {
32-
"dev": "swc --strip-leading-paths --delete-dir-on-start -s -w -d dist src",
33-
"build": "swc --strip-leading-paths --delete-dir-on-start -d dist src",
34-
"postbuild": "concurrently npm:lint npm:typecheck",
32+
"build": "rm -rf dist && tsc -p tsconfig.json && npm run lint",
3533
"format": "prettier -w src test",
3634
"lint": "eslint --cache",
37-
"typecheck": "tsc -p . --emitDeclarationOnly",
38-
"test": "c8 -c test/config/c8-local.json node --env-file=test.env --test test/*.test.ts",
39-
"test:ci": "c8 -c test/config/c8-ci.json node --env-file=test.env --test-reporter=tap --test test/*.test.ts",
40-
"ci": "npm run build && npm run test:ci",
35+
"test": "c8 -c test/config/c8-local.json node --test --test-reporter=cleaner-spec-reporter test/*.test.ts",
36+
"test:ci": "c8 -c test/config/c8-ci.json node --test --test-reporter=tap test/*.test.ts",
37+
"ci": "npm run build && npm run test",
4138
"prepublishOnly": "npm run ci",
4239
"postpublish": "git push origin && git push origin -f --tags",
43-
"generate": "node --env-file=test.env ./generate.ts"
40+
"generate": "node ./generate.ts"
4441
},
4542
"devDependencies": {
46-
"@cowtech/eslint-config": "10.2.0",
47-
"@swc-node/register": "^1.10.9",
48-
"@swc/cli": "0.5.2",
49-
"@swc/core": "^1.10.3",
50-
"@types/http-errors": "^2.0.4",
51-
"@types/node": "^22.10.2",
43+
"@cowtech/eslint-config": "^11.0.0",
44+
"@cowtech/typescript-config": "^0.2.2",
45+
"@types/http-errors": "^2.0.5",
46+
"@types/node": "^24.10.1",
5247
"c8": "^10.1.3",
53-
"chokidar": "^4.0.3",
54-
"concurrently": "^9.1.1",
55-
"eslint": "^9.17.0",
56-
"http-errors": "^2.0.0",
57-
"prettier": "^3.4.2",
58-
"typescript": "^5.7.2"
48+
"cleaner-spec-reporter": "^0.5.0",
49+
"eslint": "^9.39.1",
50+
"http-errors": "^2.0.1",
51+
"prettier": "^3.6.2",
52+
"typescript": "^5.9.3"
5953
},
6054
"engines": {
61-
"node": ">= 20.18.0"
55+
"node": ">= 22.21.0"
6256
}
6357
}

src/base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { codesByIdentifier, identifierByCodes, messagesByCodes, phrasesByCodes } from './statuses.js'
2-
import { addAdditionalProperties, serializeError, upperFirst, type GenericObject } from './utils.js'
1+
import { codesByIdentifier, identifierByCodes, messagesByCodes, phrasesByCodes } from './statuses.ts'
2+
import { addAdditionalProperties, serializeError, upperFirst, type GenericObject } from './utils.ts'
33

44
export class HttpError extends Error {
55
static standardErrorPrefix: string = 'HTTP_ERROR_'

src/errors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { HttpError } from './base.js'
2-
import { type GenericObject } from './utils.js'
1+
import { HttpError } from './base.ts'
2+
import { type GenericObject } from './utils.ts'
33

44
export class BadRequestError extends HttpError {
55
static status: number = 400

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from './base.js'
2-
export * from './errors.js'
3-
export * from './schemas.js'
4-
export * from './statuses.js'
5-
export { addAdditionalProperties, serializeError } from './utils.js'
1+
export * from './base.ts'
2+
export * from './errors.ts'
3+
export * from './schemas.ts'
4+
export * from './statuses.ts'
5+
export { addAdditionalProperties, serializeError } from './utils.ts'

src/utils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
import { sep } from 'node:path'
2+
13
export type GenericObject = Record<string, any>
24

35
export type NodeError = NodeJS.ErrnoException
46

5-
const processRoot = process.cwd()
7+
let processRoot = process.cwd()
8+
9+
/* c8 ignore next 3 - Windows specific */
10+
if (process.platform === 'win32') {
11+
processRoot = '/' + process.cwd().replaceAll(sep, '/')
12+
}
613

714
export function pascalCase(original: string): string {
815
const rest = original

test.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/base.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import createHttpError from 'http-errors'
22
import { deepStrictEqual, ok } from 'node:assert'
33
import { test } from 'node:test'
4-
import { HttpError, createError, isHttpError } from '../src/index.js'
4+
import { HttpError, createError, isHttpError } from '../src/index.ts'
55

66
test('HttpError', async () => {
77
await test('it should create a basic error', () => {

0 commit comments

Comments
 (0)