Skip to content

Commit be40dfc

Browse files
committed
chore: update library to work in node 24+
1 parent f961d15 commit be40dfc

23 files changed

Lines changed: 65 additions & 50 deletions

.github/workflows/on-push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, windows-latest] # macos-latest is too slow
12-
node-version: [20.x, 18.x]
12+
node-version: [24.x, 22.x, 20.x]
1313

1414
steps:
1515
- uses: actions/checkout@v4

.github/workflows/on-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# Setup .npmrc file to publish to npm
2323
- uses: actions/setup-node@v4
2424
with:
25-
node-version: '20.x'
25+
node-version: '24.x'
2626
# Needs to be explicitly specified for auth to work
2727
registry-url: 'https://registry.npmjs.org'
2828
- run: npm ci

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@
3232
"build:mjs": "tsc --module esnext --outDir ./bin",
3333
"build": "npm run build:mjs",
3434
"pretest": "npm run build",
35-
"test:raw": "node --loader ts-node/esm test/index.ts",
35+
"test:raw": "node test/index.ts",
3636
"test": "npm run test:raw | tap-spec",
3737
"test-with-coverage": "c8 --reporter=text npm test",
3838
"dependencies:update-internal": "npm uninstall @json2csv/formatters @json2csv/node @json2csv/transforms && npm install @json2csv/formatters @json2csv/node @json2csv/transforms",
3939
"prepublishOnly": "npm run build"
4040
},
41+
"devDependencies": {
42+
"@types/node": "^22.9.0"
43+
},
4144
"dependencies": {
4245
"@json2csv/formatters": "^7.0.7",
4346
"@json2csv/node": "^7.0.7",

packages/cli/src/json2csv.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ process.stdout.on('error', (error) => {
174174
async function getInputJSON<TRaw>(inputPath: string): Promise<TRaw> {
175175
const assert =
176176
extname(inputPath).toLowerCase() === '.json'
177-
? { assert: { type: 'json' } }
177+
? { with: { type: 'json' } }
178178
: undefined;
179-
const { default: json } = await import(`file://${inputPath}`, assert);
179+
const { default: json } = await import(`file://${inputPath}`, assert as any); // TODO remove castonce @types/node can be updated which requires updating typescript to 5.2+
180180
return json;
181181
}
182182

packages/cli/test/CLI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { promises as fsPromises } from 'fs';
22
import { join as joinPath } from 'path';
33
import { exec } from 'child_process';
44
import { promisify } from 'util';
5-
import TestRunner from '@json2csv/test-helpers/TestRunner.js';
5+
import TestRunner from '@json2csv/test-helpers/TestRunner.ts';
66

77
const { mkdir, rm, readFile } = fsPromises;
88

packages/cli/test/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { fixtures } from '@json2csv/test-helpers/fixtureLoader.js';
1+
import { fixtures } from '@json2csv/test-helpers/fixtureLoader.ts';
22

3-
import CLI from './CLI.js';
4-
import parseNdjson from './parseNdjson.js';
3+
import CLI from './CLI.ts';
4+
import parseNdjson from './parseNdjson.ts';
55

66
async function run() {
77
const { jsonFixtures, csvFixtures } = await fixtures;

packages/cli/test/parseNdjson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import TestRunner from '@json2csv/test-helpers/TestRunner.js';
1+
import TestRunner from '@json2csv/test-helpers/TestRunner.ts';
22
import parsendjson from '../bin/utils/parseNdjson.js';
33

44
export default function (jsonFixtures: Record<string, () => any>) {

packages/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"pretest": "npm run build",
4444
"test": "node test/CommonJS.cjs && npm run test:raw | tap-spec",
4545
"test-with-coverage": "c8 --reporter=text npm test",
46-
"test:raw": "node --loader ts-node/esm test/index.ts",
46+
"test:raw": "node test/index.ts",
4747
"dependencies:update-internal": "npm uninstall @json2csv/plainjs && npm install @json2csv/plainjs",
4848
"prepublishOnly": "npm run build"
4949
},

packages/node/test/AsyncParser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { type Readable, Writable } from 'stream';
22

3-
import TestRunner from '@json2csv/test-helpers/TestRunner.js';
4-
import { forceLfEol } from '@json2csv/test-helpers/utils.js';
5-
import type CarInfo from '@json2csv/test-helpers/fixtures/types/carInfo.js';
3+
import TestRunner from '@json2csv/test-helpers/TestRunner.ts';
4+
import { forceLfEol } from '@json2csv/test-helpers/utils.ts';
5+
import type CarInfo from '@json2csv/test-helpers/fixtures/types/carInfo.ts';
66
import { flatten, unwind } from '@json2csv/transforms';
77
import {
88
number as numberFormatter,

0 commit comments

Comments
 (0)