Skip to content

Commit

Permalink
feat: add ProcessPromise.valueOf() (#737)
Browse files Browse the repository at this point in the history
closes #690
  • Loading branch information
antongolub committed Mar 18, 2024
1 parent b38972e commit 0640b80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core.ts
Expand Up @@ -448,6 +448,10 @@ export class ProcessOutput extends Error {
return this._combined
}

valueOf() {
return this._combined.trim()
}

get stdout() {
return this._stdout
}
Expand Down
11 changes: 11 additions & 0 deletions test/core.test.js
Expand Up @@ -188,6 +188,17 @@ describe('core', () => {
assert.ok(p5 !== p1)
})

test('ProcessPromise: implements toString()', async () => {
const p = $`echo foo`
assert.equal((await p).toString(), 'foo\n')
})

test('ProcessPromise: implements valueOf()', async () => {
const p = $`echo foo`
assert.equal((await p).valueOf(), 'foo')
assert.ok((await p) == 'foo')
})

test('cd() works with relative paths', async () => {
let cwd = process.cwd()
try {
Expand Down

0 comments on commit 0640b80

Please sign in to comment.