Skip to content

Commit 6d941e8

Browse files
committedFeb 11, 2025
test: check pipe() on inappropriate ProcessPromise
1 parent 1cc5981 commit 6d941e8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎src/core.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
232232
let reject: Resolve
233233
super((...args) => {
234234
;[resolve, reject] = args
235-
executor?.(...args)
235+
executor(...args)
236236
})
237237

238238
if (bound.length) {

‎test/core.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,15 @@ describe('core', () => {
575575
assert.equal(p.stdout.trim(), 'foo')
576576
})
577577

578+
test('detects inappropriate ProcessPromise', async () => {
579+
const foo = $`echo foo`
580+
const p1 = $`cat`
581+
const p2 = p1.then((v) => v)
582+
583+
assert.throws(() => foo.pipe(p2), /Inappropriate usage/)
584+
await foo.pipe(p1)
585+
})
586+
578587
test('accepts $ template literal', async () => {
579588
const p = await $`echo foo`.pipe`cat`
580589
assert.equal(p.stdout.trim(), 'foo')

0 commit comments

Comments
 (0)