Skip to content

Commit 7822cee

Browse files
authored
fix: hide tsc --showConfig output since its used for validation only (#716)
1 parent aabe5dd commit 7822cee

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

.changeset/moody-pugs-drive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/backend-deployer': patch
3+
---
4+
5+
fix: hide tsc --showConfig output since its used for validation only

packages/backend-deployer/src/cdk_deployer.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,16 @@ export class CDKDeployer implements BackendDeployer {
7878
return;
7979
}
8080
try {
81-
await this.executeChildProcess('npx', [
82-
'tsc',
83-
'--showConfig',
84-
'--project',
85-
dirname(this.backendLocator.locate()),
86-
]);
81+
await this.executeChildProcess(
82+
'npx',
83+
[
84+
'tsc',
85+
'--showConfig',
86+
'--project',
87+
dirname(this.backendLocator.locate()),
88+
],
89+
{ printStdout: false }
90+
);
8791
} catch (error) {
8892
// If we cannot load ts config, turn off type checking
8993
return;
@@ -157,7 +161,11 @@ export class CDKDeployer implements BackendDeployer {
157161
* Wrapper for the child process executor. Helps in unit testing as node:test framework
158162
* doesn't have capabilities to mock exported functions like `execa` as of right now.
159163
*/
160-
executeChildProcess = async (command: string, cdkCommandArgs: string[]) => {
164+
executeChildProcess = async (
165+
command: string,
166+
commandArgs: string[],
167+
options: { printStdout: boolean } = { printStdout: true }
168+
) => {
161169
// We let the stdout and stdin inherit and streamed to parent process but pipe
162170
// the stderr and use it to throw on failure. This is to prevent actual
163171
// actionable errors being hidden among the stdout. Moreover execa errors are
@@ -169,7 +177,7 @@ export class CDKDeployer implements BackendDeployer {
169177
done();
170178
};
171179

172-
const childProcess = execa(command, cdkCommandArgs, {
180+
const childProcess = execa(command, commandArgs, {
173181
stdin: 'inherit',
174182
stdout: 'pipe',
175183
stderr: 'pipe',
@@ -180,7 +188,10 @@ export class CDKDeployer implements BackendDeployer {
180188
env: { FORCE_COLOR: '1' },
181189
});
182190
childProcess.stderr?.pipe(aggregatorStderrStream);
183-
childProcess.stdout?.pipe(process.stdout);
191+
192+
if (options?.printStdout) {
193+
childProcess.stdout?.pipe(process.stdout);
194+
}
184195

185196
const cdkOutput = { deploymentTimes: {} };
186197
if (childProcess.stdout) {

0 commit comments

Comments
 (0)