Skip to content

Commit d67bff9

Browse files
authored
chore: remove split2 (#36)
1 parent 4a79cca commit d67bff9

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ Typical usage:
1717

1818
```js
1919
import { spawn } from 'node:child_process'
20-
import split2 from 'split2'
20+
import { createInterface } from 'node:readline'
21+
import { Readable } from 'node:stream'
2122
import listStream from 'list-stream'
2223

23-
spawn('bash', ['-c', 'git log'])
24-
.stdout.pipe(split2()) // break up by newline characters
24+
const { stdout } = spawn('bash', ['-c', 'git log'])
25+
26+
Readable.from(createInterface({ input: stdout, crlfDelay: Infinity })) // break up by newline characters
2527
.pipe(commitStream('rvagg', 'commit-stream'))
2628
.pipe(listStream.obj(onCommitList))
2729

‎package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"@semantic-release/git": "^11.0.0",
2525
"conventional-changelog-conventionalcommits": "^9.3.1",
2626
"list-stream": "^2.1.0",
27-
"semantic-release": "^25.0.3",
28-
"split2": "^4.2.0"
27+
"semantic-release": "^25.0.3"
2928
},
3029
"release": {
3130
"branches": [

‎test.js‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import commitStream from './commit-stream.js'
22
import { spawn, exec } from 'node:child_process'
33
import assert from 'node:assert/strict'
44
import nodeTest from 'node:test'
5-
import split2 from 'split2'
5+
import { createInterface } from 'node:readline'
66
import listStream from 'list-stream'
7-
import { pipeline } from 'node:stream'
7+
import { pipeline, Readable } from 'node:stream'
88

99
function test (name, fn) {
1010
return nodeTest(name, (_, done) => fn({
@@ -21,6 +21,10 @@ function gitToList (t, gitCmd, user, repo, callback) {
2121
repo = undefined
2222
}
2323
const child = spawn('bash', ['-c', gitCmd])
24+
let pending = 2
25+
const done = () => {
26+
if (--pending === 0) setImmediate(t.end.bind(t))
27+
}
2428
let stderr = ''
2529
child.stderr.setEncoding('utf8').on('data', (chunk) => { stderr += chunk })
2630
child.on('error', (err) => {
@@ -29,13 +33,15 @@ function gitToList (t, gitCmd, user, repo, callback) {
2933
child.on('close', (code) => {
3034
t.strictEqual(stderr, '')
3135
t.strictEqual(code, 0, 'exit code zero')
32-
setImmediate(t.end.bind(t))
36+
done()
3337
})
3438
pipeline(
35-
child.stdout,
36-
split2(),
39+
Readable.from(createInterface({ input: child.stdout, crlfDelay: Infinity })),
3740
commitStream(user, repo),
38-
listStream.obj(callback),
41+
listStream.obj((err, list) => {
42+
callback(err, list)
43+
done()
44+
}),
3945
() => {}
4046
)
4147
}

0 commit comments

Comments
 (0)