Skip to content

Commit 0640b80

Browse files
authored
feat: add ProcessPromise.valueOf() (google#737)
closes google#690
1 parent b38972e commit 0640b80

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/core.ts

+4
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ export class ProcessOutput extends Error {
448448
return this._combined
449449
}
450450

451+
valueOf() {
452+
return this._combined.trim()
453+
}
454+
451455
get stdout() {
452456
return this._stdout
453457
}

test/core.test.js

+11
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@ describe('core', () => {
188188
assert.ok(p5 !== p1)
189189
})
190190

191+
test('ProcessPromise: implements toString()', async () => {
192+
const p = $`echo foo`
193+
assert.equal((await p).toString(), 'foo\n')
194+
})
195+
196+
test('ProcessPromise: implements valueOf()', async () => {
197+
const p = $`echo foo`
198+
assert.equal((await p).valueOf(), 'foo')
199+
assert.ok((await p) == 'foo')
200+
})
201+
191202
test('cd() works with relative paths', async () => {
192203
let cwd = process.cwd()
193204
try {

0 commit comments

Comments
 (0)