@@ -56,23 +56,34 @@ export function getKomposeOutput(logs: string) {
56
56
isError : false ,
57
57
} ;
58
58
59
- const errorMatch = logs . match ( / K O M P O S E _ E R R O R = ( .+ ) _ _ E N D E R R O R _ _ / g) ;
60
- if ( ! ! errorMatch ) {
61
- output . isError = true ;
62
- output . data = errorMatch [ 0 ] . slice ( 'KOMPOSE_ERROR=' . length , - '__ENDERROR__' . length ) ;
63
- return output ;
59
+ // Look for the error block
60
+ const errorStart = logs . indexOf ( 'KOMPOSE_ERROR=' ) ;
61
+ if ( errorStart !== - 1 ) {
62
+ const errorEnd = logs . indexOf ( '__ENDERROR__' , errorStart ) ;
63
+ if ( errorEnd !== - 1 ) {
64
+ output . isError = true ;
65
+ output . data = logs . slice ( errorStart + 'KOMPOSE_ERROR=' . length , errorEnd ) ;
66
+ return output ;
67
+ }
64
68
}
65
69
66
- const match = logs . match ( / K O M P O S E _ O U T P U T = ( [ A - Z a - z 0 - 9 \s = ] + ) _ _ E N D O U T P U T _ _ / g) ;
67
- if ( ! ! match ) {
68
- const komposeYAML = atob (
69
- match [ 0 ] . slice ( 'KOMPOSE_OUTPUT=' . length , - '__ENDOUTPUT__' . length ) . replace ( / / g, '\n' )
70
- ) ;
71
- output . data = komposeYAML ;
72
- } else {
73
- output . isError = true ;
74
- output . data = 'Failed to get any output from conversion.' ;
70
+ // Look for the output block
71
+ const outputStart = logs . indexOf ( 'KOMPOSE_OUTPUT=' ) ;
72
+ if ( outputStart !== - 1 ) {
73
+ const outputEnd = logs . indexOf ( '__ENDOUTPUT__' , outputStart ) ;
74
+ if ( outputEnd !== - 1 ) {
75
+ const encoded = logs . slice ( outputStart + 'KOMPOSE_OUTPUT=' . length , outputEnd ) ;
76
+ try {
77
+ output . data = atob ( encoded . replace ( / / g, '\n' ) ) ;
78
+ } catch ( e ) {
79
+ output . isError = true ;
80
+ output . data = 'Failed to decode kompose output.' ;
81
+ }
82
+ return output ;
83
+ }
75
84
}
76
85
86
+ output . isError = true ;
87
+ output . data = 'Failed to get any output from conversion.' ;
77
88
return output ;
78
89
}
0 commit comments