Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 build/core.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ var _ProcessOutput = class _ProcessOutput extends Error {
return !this._dto.error && this.exitCode === 0;
}
json() {
return JSON.parse(this.stdall);
return JSON.parse(this.stdout);
}
buffer() {
return import_node_buffer.Buffer.from(this.stdall);
Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ export class ProcessOutput extends Error {
}

json<T = any>(): T {
return JSON.parse(this.stdall)
return JSON.parse(this.stdout)
}

buffer(): Buffer {
Expand Down
19 changes: 18 additions & 1 deletion test/core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1495,14 +1495,31 @@ describe('core', () => {
assert.equal(o.toString(), 'foo\n')
})

test('json() parses stdout, not the combined stdout+stderr', async () => {
const o = new ProcessOutput(
0,
null,
'{"ok":true}',
'progress...',
'progress...{"ok":true}'
)
assert.deepEqual(o.json(), { ok: true })
})

test('valueOf()', async () => {
const o = new ProcessOutput(null, null, '', '', 'foo\n')
assert.equal(o.valueOf(), 'foo')
assert.ok(o == 'foo')
})

test('json()', async () => {
const o = new ProcessOutput(null, null, '', '', '{"key":"value"}')
const o = new ProcessOutput(
null,
null,
'{"key":"value"}',
'',
'{"key":"value"}'
)
assert.deepEqual(o.json(), { key: 'value' })
})

Expand Down