@@ -3,28 +3,32 @@ import { promisify } from 'node:util';
33import { getEnvConfig } from '../config/config' ;
44
55const execAsync = promisify ( exec ) ;
6+ const NEWLINE_SEPARATOR = / \r \n | \r | \n / ;
7+ const STDOUT_PREFIX = / ^ [ a - z ] + : / ;
68
7- export function extractDataFromStdOut ( output : string ) : string {
9+ export function removePrefixFromStdOut ( output : string ) : string {
810 return output
9- . split ( / \r \n | \r | \n / )
10- . filter ( line => line . startsWith ( 'data: ' ) )
11- . map ( line => line . replace ( 'data: ' , '' ) )
11+ . split ( NEWLINE_SEPARATOR )
12+ . map ( line => line . replace ( STDOUT_PREFIX , '' ) )
1213 . join ( '\n' ) ;
1314}
1415
15- export function removePrefixFromStdOut ( output : string ) : string {
16- return output
17- . split ( / \r \n | \r | \n / )
18- . map ( line => line . replace ( / ^ [ a - z ] + : / , '' ) )
19- . join ( '\n' ) ;
16+ export function getDataFromStdOut ( output : string ) : string {
17+ return removePrefixFromStdOut (
18+ output
19+ . split ( NEWLINE_SEPARATOR )
20+ . filter ( line => line . startsWith ( 'data:' ) )
21+ . join ( '\n' ) ,
22+ ) ;
2023}
2124
2225export function getErrorsFromStdOut ( output : string ) : string {
23- return output
24- . split ( / \r \n | \r | \n / )
25- . filter ( line => line . startsWith ( 'error:' ) )
26- . map ( line => line . replace ( / ^ [ a - z ] + : / , '' ) )
27- . join ( '\n' ) ;
26+ return removePrefixFromStdOut (
27+ output
28+ . split ( NEWLINE_SEPARATOR )
29+ . filter ( line => line . startsWith ( 'error:' ) )
30+ . join ( '\n' ) ,
31+ ) ;
2832}
2933
3034export async function execEF (
0 commit comments