Skip to content

Commit 21684cb

Browse files
Fix readCSV utility issue with special character U+2029 having a different behaviour in node:readline in node.js 24
1 parent c44fc8c commit 21684cb

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

.harness/ci.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pipeline:
3737
steps:
3838
- step:
3939
type: Run
40-
name: redis-server
40+
name: Install and run redis-server
4141
identifier: redis_server
4242
spec:
4343
shell: Sh
@@ -46,13 +46,12 @@ pipeline:
4646
redis-server --daemonize yes
4747
- step:
4848
type: Action
49-
name: Set up Nodejs
49+
name: Set up Node.js
5050
identifier: Set_up_Nodejs
5151
spec:
52-
uses: actions/setup-node@v4
52+
uses: dcodeIO/setup-node-nvm@master
5353
with:
54-
node-version: "20"
55-
cache: npm
54+
node-version: lts/*
5655
- step:
5756
type: Run
5857
name: npm ci

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22
1+
lts/*

package-lock.json

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

src/__tests__/testUtils/csv.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import fs from 'fs';
2-
import rl from 'readline';
32

43
export function readCSV(filePath: string, delimiter = ','): Promise<string[][]> {
5-
return new Promise((resolve) => {
6-
const parser = rl.createInterface({
7-
input: fs.createReadStream(filePath)
8-
});
4+
return new Promise((resolve, reject) => {
5+
fs.readFile(filePath, 'utf8', (err, content) => {
6+
if (err) return reject(err);
97

10-
const data: string[][] = [];
8+
const lines = content.split(/\r?\n/);
9+
const data = lines
10+
.filter(line => line.trim().length > 0)
11+
.map(line => line.split(delimiter));
1112

12-
parser
13-
.on('line', line => {
14-
data.push(line.split(delimiter));
15-
})
16-
.on('close', () => resolve(data));
13+
resolve(data);
14+
});
1715
});
1816
}

0 commit comments

Comments
 (0)