Skip to content

Commit

Permalink
fix: always log stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
iowillhoit committed Jan 31, 2023
1 parent 16773eb commit a5a942f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/commands/cli/release/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { promisify } from 'node:util';
import { exec as execSync } from 'child_process';
import { exec as execSync, ExecException } from 'child_process';
import { arrayWithDeprecation, Flags, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { ensureString } from '@salesforce/ts-types';
import { Env } from '@salesforce/kit';
Expand Down Expand Up @@ -222,12 +222,22 @@ export default class build extends SfCommand<void> {
private async exec(command: string, silent = false): Promise<string> {
try {
const { stdout } = await exec(command);

if (!silent) {
this.styledHeader(command);
this.log(stdout);
}

return stdout;
} catch (err) {
// An error will throw before `stdout` is able to be log above. The child_process.exec adds stdout and stderr to the error object
const error = err as ExecException & {
stdout: string;
stderr: string;
};

this.log(error.stdout);

throw new SfError((err as Error).message);
}
}
Expand Down

0 comments on commit a5a942f

Please sign in to comment.