@@ -27,6 +27,36 @@ let swiftTestCommand = [
2727 'VizzlyE2ETests' ,
2828] . join ( ' ' ) ;
2929
30+ function cleanupAndExit ( code = 1 ) {
31+ rmSync ( tempDir , { recursive : true , force : true } ) ;
32+ process . exit ( code ) ;
33+ }
34+
35+ function printLocalContext ( ) {
36+ let contextResult = spawnSync (
37+ process . execPath ,
38+ [ cliPath , 'context' , 'build' , 'current' , '--source' , 'local' , '--agent' ] ,
39+ {
40+ cwd : tempDir ,
41+ encoding : 'utf8' ,
42+ env : {
43+ ...process . env ,
44+ VIZZLY_HOME : vizzlyHome ,
45+ } ,
46+ }
47+ ) ;
48+
49+ if ( contextResult . stdout ) {
50+ process . stdout . write ( contextResult . stdout ) ;
51+ }
52+
53+ if ( contextResult . stderr ) {
54+ process . stderr . write ( contextResult . stderr ) ;
55+ }
56+
57+ return contextResult . status ?? 1 ;
58+ }
59+
3060let child = spawn (
3161 process . execPath ,
3262 [ cliPath , 'tdd' , 'run' , swiftTestCommand , '--no-color' ] ,
@@ -42,40 +72,15 @@ let child = spawn(
4272) ;
4373
4474child . on ( 'exit' , code => {
45- if ( code === 0 ) {
46- let contextResult = spawnSync (
47- process . execPath ,
48- [ cliPath , 'context' , 'build' , 'current' , '--source' , 'local' , '--agent' ] ,
49- {
50- cwd : tempDir ,
51- encoding : 'utf8' ,
52- env : {
53- ...process . env ,
54- VIZZLY_HOME : vizzlyHome ,
55- } ,
56- }
57- ) ;
58-
59- if ( contextResult . stdout ) {
60- process . stdout . write ( contextResult . stdout ) ;
61- }
62-
63- if ( contextResult . stderr ) {
64- process . stderr . write ( contextResult . stderr ) ;
65- }
66-
67- if ( contextResult . status !== 0 ) {
68- rmSync ( tempDir , { recursive : true , force : true } ) ;
69- process . exit ( contextResult . status ?? 1 ) ;
70- }
75+ if ( code !== 0 ) {
76+ cleanupAndExit ( code ?? 1 ) ;
7177 }
7278
73- rmSync ( tempDir , { recursive : true , force : true } ) ;
74- process . exit ( code ?? 1 ) ;
79+ let contextStatus = printLocalContext ( ) ;
80+ cleanupAndExit ( contextStatus ) ;
7581} ) ;
7682
7783child . on ( 'error' , error => {
78- rmSync ( tempDir , { recursive : true , force : true } ) ;
7984 console . error ( error ) ;
80- process . exit ( 1 ) ;
85+ cleanupAndExit ( 1 ) ;
8186} ) ;
0 commit comments