1
+ import { Console } from 'node:console' ;
1
2
import { readFile } from 'node:fs/promises' ;
2
3
import { tmpdir } from 'node:os' ;
3
4
import { join } from 'node:path' ;
@@ -11,6 +12,11 @@ import { App, Stack } from 'aws-cdk-lib';
11
12
import { generateTestUniqueName } from './helpers.js' ;
12
13
import type { TestStackProps } from './types.js' ;
13
14
15
+ const testConsole = new Console ( {
16
+ stdout : process . stdout ,
17
+ stderr : process . stderr ,
18
+ } ) ;
19
+
14
20
/**
15
21
* Test stack that can be deployed to the selected environment.
16
22
*/
@@ -46,6 +52,11 @@ class TestStack {
46
52
* Reference to the AWS CDK Cloud Assembly context.
47
53
*/
48
54
#cx?: ICloudAssemblySource ;
55
+ /**
56
+ * @internal
57
+ * Reference to the console object.
58
+ */
59
+ static #console: Console ;
49
60
50
61
public constructor ( { stackNameProps, app, stack } : TestStackProps ) {
51
62
this . testName = generateTestUniqueName ( {
@@ -58,10 +69,16 @@ class TestStack {
58
69
color : false ,
59
70
ioHost : {
60
71
async notify ( msg ) {
61
- console . log ( msg ) ;
72
+ if ( process . env . ACTIONS_RUNNER_DEBUG === 'true' ) {
73
+ testConsole . log ( msg ) ;
74
+ } else {
75
+ if ( [ 'info' , 'warning' , 'error' ] . includes ( msg . level ) ) {
76
+ testConsole . log ( msg ) ;
77
+ }
78
+ }
62
79
} ,
63
80
async requestResponse ( msg ) {
64
- console . log ( msg ) ;
81
+ testConsole . log ( msg ) ;
65
82
return msg . defaultResponse ;
66
83
} ,
67
84
} ,
0 commit comments