11import arg from 'arg' ;
22import chalkTemplate from 'chalk-template' ;
3- import { existsSync , readFileSync , writeFileSync } from 'fs' ;
3+ import { existsSync , readFileSync , writeFileSync , createWriteStream } from 'fs' ;
44import path , { join } from 'path' ;
55import YAML from 'yaml' ;
66import { APIClient } from './APIClient.js' ;
@@ -28,6 +28,7 @@ async function main() {
2828 '--version' : Boolean ,
2929 '--expect-text' : String ,
3030 '--fail-text' : String ,
31+ '--serial-log-file' : String ,
3132 '--scenario' : String ,
3233 '--screenshot-part' : String ,
3334 '--screenshot-file' : String ,
@@ -43,6 +44,7 @@ async function main() {
4344 const quiet = args [ '--quiet' ] ;
4445 const expectText = args [ '--expect-text' ] ;
4546 const failText = args [ '--fail-text' ] ;
47+ const serialLogFile = args [ '--serial-log-file' ] ;
4648 const scenarioFile = args [ '--scenario' ] ;
4749 const timeout = args [ '--timeout' ] ?? 30000 ;
4850 const screenshotPart = args [ '--screenshot-part' ] ;
@@ -126,6 +128,8 @@ async function main() {
126128 scenario . validate ( ) ;
127129 }
128130
131+ const serialLogStream = serialLogFile ? createWriteStream ( serialLogFile ) : null ;
132+
129133 if ( expectText ) {
130134 expectEngine . expectTexts . push ( expectText ) ;
131135 expectEngine . on ( 'match' , ( text ) => {
@@ -219,6 +223,8 @@ async function main() {
219223 for ( const byte of bytes ) {
220224 process . stdout . write ( String . fromCharCode ( byte ) ) ;
221225 }
226+
227+ serialLogStream ?. write ( Buffer . from ( bytes ) ) ;
222228 expectEngine . feed ( bytes ) ;
223229 }
224230 if ( event . event === 'chips:log' ) {
0 commit comments