Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: check pipe() on inappropriate ProcessPromise #1098

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
let reject: Resolve
super((...args) => {
;[resolve, reject] = args
executor?.(...args)
executor(...args)
})

if (bound.length) {
Expand Down
9 changes: 9 additions & 0 deletions test/core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,15 @@ describe('core', () => {
assert.equal(p.stdout.trim(), 'foo')
})

test('detects inappropriate ProcessPromise', async () => {
const foo = $`echo foo`
const p1 = $`cat`
const p2 = p1.then((v) => v)

assert.throws(() => foo.pipe(p2), /Inappropriate usage/)
await foo.pipe(p1)
})

test('accepts $ template literal', async () => {
const p = await $`echo foo`.pipe`cat`
assert.equal(p.stdout.trim(), 'foo')
Expand Down