diff --git a/build/core.cjs b/build/core.cjs index cd9f1f0706..98337f0c12 100644 --- a/build/core.cjs +++ b/build/core.cjs @@ -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); diff --git a/src/core.ts b/src/core.ts index 39c320149f..ad69630f1f 100644 --- a/src/core.ts +++ b/src/core.ts @@ -934,7 +934,7 @@ export class ProcessOutput extends Error { } json(): T { - return JSON.parse(this.stdall) + return JSON.parse(this.stdout) } buffer(): Buffer { diff --git a/test/core.test.js b/test/core.test.js index b80a2eda91..ac73eb94e3 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -1495,6 +1495,17 @@ 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') @@ -1502,7 +1513,13 @@ describe('core', () => { }) 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' }) })