Skip to content

Commit 7ed14e3

Browse files
authored
Breaking: bump tap-completed from 1 to 2 (#339)
Fixes #334. Breaking because it drops support of Node.js < 20. Ref: https://github.com/vweevers/tap-completed/releases/tag/v2.0.0 Category: change
1 parent 529e4fc commit 7ed14e3

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
node: [10, 12, 14, 16]
12+
node: [20, 22]
1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@v3

bin/airtap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22
'use strict'
33

4-
if (process.version.match(/^v(\d+)\./)[1] < 10) {
5-
console.error('airtap: Node 10 or greater is required. `airtap` did not run.')
4+
if (process.version.match(/^v(\d+)\./)[1] < 20) {
5+
console.error('airtap: Node 20 or greater is required. `airtap` did not run.')
66
process.exit(0)
77
}
88

lib/browser-session.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const kResetIdleTimer = Symbol('kResetIdleTimer')
1919
const kTimeout = Symbol('kTimeout')
2020
const kClientErrored = Symbol('kClientErrored')
2121
const kCwd = Symbol('kCwd')
22+
const kHandleComplete = Symbol('kHandleComplete')
2223

2324
let seq = 0
2425

@@ -50,27 +51,34 @@ class BrowserSession extends Transform {
5051

5152
// Don't care about diagnostics after completion, don't wait.
5253
this[kParser] = Parser({ wait: 0 })
54+
this[kHandleComplete] = this[kHandleComplete].bind(this)
5355

5456
this[kResetIdleTimer]()
55-
this[kParser].on('complete', (results) => {
56-
this.stats.ok = results.ok
57-
this.stats.pass = results.pass
58-
this.stats.fail = results.fail
59-
60-
debug('session %o complete (%s)', this[kTitle], this.stats.ok ? 'ok' : 'not ok')
61-
this.emit('complete', this.stats)
62-
})
57+
this[kParser].on('complete', this[kHandleComplete])
6358

6459
debug('session %o', this[kTitle])
6560
}
6661

6762
_destroy (reason, cb) {
6863
if (reason) debug('destroy %o: %O', this[kTitle], reason)
6964
clearTimeout(this[kIdleTimer])
65+
66+
// Destroying also results in a 'complete' event
67+
this[kParser].removeListener('complete', this[kHandleComplete])
7068
this[kParser].destroy()
69+
7170
cb(reason)
7271
}
7372

73+
[kHandleComplete] (results) {
74+
this.stats.ok = results.ok
75+
this.stats.pass = results.pass
76+
this.stats.fail = results.fail
77+
78+
debug('session %o complete (%s)', this[kTitle], this.stats.ok ? 'ok' : 'not ok')
79+
this.emit('complete', this.stats)
80+
}
81+
7482
[kResetIdleTimer] () {
7583
if (this[kIdleTimer]) {
7684
this[kIdleTimer].refresh()
@@ -109,11 +117,10 @@ class BrowserSession extends Transform {
109117
this.push(line)
110118
}
111119

112-
if (!this[kParser].write(line)) {
113-
this[kParser].once('drain', next)
114-
} else {
115-
next()
116-
}
120+
// Has no backpressure. Just keep writing.
121+
this[kParser].write(line)
122+
123+
next()
117124
} else if (msg.type === 'error' && msg.fatal) {
118125
next(new Error(String(msg.message || 'Client error')))
119126
} else if (msg.type === 'error') {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"run-parallel-settled": "^1.0.1",
5151
"server-destroy": "^1.0.1",
5252
"shell-quote": "^1.7.0",
53-
"tap-completed": "^1.0.0",
53+
"tap-completed": "^2.0.0",
5454
"thunky-with-args": "^1.0.0",
5555
"transient-error": "^1.0.0",
5656
"uuid": "^8.3.0",
@@ -85,6 +85,6 @@
8585
"testing"
8686
],
8787
"engines": {
88-
"node": ">=10.2"
88+
"node": ">=20"
8989
}
9090
}

0 commit comments

Comments
 (0)