1
- import * as fs from 'node:fs' ;
2
1
import * as path from 'node:path' ;
3
2
import { Transform } from 'node:stream' ;
4
3
import * as childProcess from 'node:child_process' ;
5
4
import * as process from 'node:process' ;
6
5
7
6
const escapeSequenceRegex = new RegExp (
8
- // eslint-disable-next-line no-control-regex
9
7
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' ,
10
8
'g' ,
11
9
) ;
12
10
13
11
export function playwrightRecorder ( ) {
14
- const assetsPath = path . join ( process . cwd ( ) , '__assets__' ) ;
15
- if ( ! fs . existsSync ( assetsPath ) ) {
16
- fs . mkdirSync ( assetsPath ) ;
17
- }
18
- const ws = fs . createWriteStream ( path . join ( assetsPath , 'console.log' ) , {
19
- flags : 'w+' ,
20
- mode : 0o644 ,
21
- } ) ;
22
12
const stripAsciiTransform = new Transform ( {
23
13
transform ( chunk , _ , callback ) {
24
14
// list reporter uses escape codes to rewrite lines, strip them to make console output more readable
@@ -34,11 +24,8 @@ export function playwrightRecorder() {
34
24
35
25
child . stdout . pipe ( stripAsciiTransform ) . pipe ( process . stdout ) ;
36
26
child . stderr . pipe ( process . stderr ) ;
37
- child . stdout . pipe ( ws ) ;
38
- child . stderr . pipe ( ws ) ;
39
27
40
28
child . on ( 'exit' , ( exitCode ) => {
41
- ws . end ( ) ;
42
29
process . exit ( exitCode ?? 1 ) ;
43
30
} ) ;
44
31
}
0 commit comments