1
1
import arg from 'arg' ;
2
2
import chalkTemplate from 'chalk-template' ;
3
- import { existsSync , readFileSync , writeFileSync } from 'fs' ;
3
+ import { existsSync , readFileSync , writeFileSync , createWriteStream } from 'fs' ;
4
4
import path , { join } from 'path' ;
5
5
import YAML from 'yaml' ;
6
6
import { APIClient } from './APIClient.js' ;
@@ -28,6 +28,7 @@ async function main() {
28
28
'--version' : Boolean ,
29
29
'--expect-text' : String ,
30
30
'--fail-text' : String ,
31
+ '--serial-log-file' : String ,
31
32
'--scenario' : String ,
32
33
'--screenshot-part' : String ,
33
34
'--screenshot-file' : String ,
@@ -43,6 +44,7 @@ async function main() {
43
44
const quiet = args [ '--quiet' ] ;
44
45
const expectText = args [ '--expect-text' ] ;
45
46
const failText = args [ '--fail-text' ] ;
47
+ const serialLogFile = args [ '--serial-log-file' ] ;
46
48
const scenarioFile = args [ '--scenario' ] ;
47
49
const timeout = args [ '--timeout' ] ?? 30000 ;
48
50
const screenshotPart = args [ '--screenshot-part' ] ;
@@ -126,6 +128,8 @@ async function main() {
126
128
scenario . validate ( ) ;
127
129
}
128
130
131
+ const serialLogStream = serialLogFile ? createWriteStream ( serialLogFile ) : null ;
132
+
129
133
if ( expectText ) {
130
134
expectEngine . expectTexts . push ( expectText ) ;
131
135
expectEngine . on ( 'match' , ( text ) => {
@@ -219,6 +223,8 @@ async function main() {
219
223
for ( const byte of bytes ) {
220
224
process . stdout . write ( String . fromCharCode ( byte ) ) ;
221
225
}
226
+
227
+ serialLogStream ?. write ( Buffer . from ( bytes ) ) ;
222
228
expectEngine . feed ( bytes ) ;
223
229
}
224
230
if ( event . event === 'chips:log' ) {
0 commit comments