Skip to content

Commit 5cad241

Browse files
committed
feat: support signal opt
closes google#768 relates google#734
1 parent 7fa9bfc commit 5cad241

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

package-lock.json

+12-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"typescript": "^5.4.4",
8181
"which": "^4.0.0",
8282
"yaml": "^2.4.1",
83-
"zurk": "^0.0.32"
83+
"zurk": "^0.1.0"
8484
},
8585
"publishConfig": {
8686
"registry": "https://wombat-dressing-room.appspot.com"

src/core.ts

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface Options {
5757
[syncExec]: boolean
5858
cwd?: string
5959
ac?: AbortController
60+
signal?: AbortSignal
6061
input?: string | Buffer | Readable | ProcessOutput | ProcessPromise
6162
verbose: boolean
6263
sync: boolean
@@ -247,6 +248,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
247248
cmd: $.prefix + this._command + $.postfix,
248249
cwd: $.cwd ?? $[processCwd],
249250
ac: $.ac,
251+
signal: $.signal,
250252
shell: typeof $.shell === 'string' ? $.shell : true,
251253
env: $.env,
252254
spawn: $.spawn,

test/core.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,20 @@ describe('core', () => {
342342
}
343343
})
344344

345+
test('accepts AbortController `signal` separately', async () => {
346+
const ac = new AbortController()
347+
const signal = ac.signal
348+
const p = $({ signal })`sleep 9999`
349+
setTimeout(() => ac.abort(), 100)
350+
351+
try {
352+
await p
353+
assert.unreachable('should have thrown')
354+
} catch ({ message }) {
355+
assert.match(message, /The operation was aborted/)
356+
}
357+
})
358+
345359
test('kill() method works', async () => {
346360
let p = $`sleep 9999`.nothrow()
347361
setTimeout(() => {

test/fixtures/js-project/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)