@@ -249,13 +249,33 @@ namespace Playback {
249
249
wrapper . endRecord = ( ) => {
250
250
if ( recordLog !== undefined ) {
251
251
let i = 0 ;
252
- const fn = ( ) => recordLogFileNameBase + i ;
253
- while ( underlying . fileExists ( ts . combinePaths ( fn ( ) , "test.json" ) ) ) i ++ ;
254
- underlying . writeFile ( ts . combinePaths ( fn ( ) , "test.json" ) , JSON . stringify ( oldStyleLogIntoNewStyleLog ( recordLog , ( path , string ) => underlying . writeFile ( path , string ) , fn ( ) ) , null , 4 ) ) ; // tslint:disable-line:no-null-keyword
252
+ const getBase = ( ) => recordLogFileNameBase + i ;
253
+ while ( underlying . fileExists ( ts . combinePaths ( getBase ( ) , "test.json" ) ) ) i ++ ;
254
+ const newLog = oldStyleLogIntoNewStyleLog ( recordLog , ( path , string ) => underlying . writeFile ( path , string ) , getBase ( ) ) ;
255
+ underlying . writeFile ( ts . combinePaths ( getBase ( ) , "test.json" ) , JSON . stringify ( newLog , null , 4 ) ) ; // tslint:disable-line:no-null-keyword
256
+ const syntheticTsconfig = generateTsconfig ( newLog ) ;
257
+ if ( syntheticTsconfig ) {
258
+ underlying . writeFile ( ts . combinePaths ( getBase ( ) , "tsconfig.json" ) , JSON . stringify ( syntheticTsconfig , null , 4 ) ) ; // tslint:disable-line:no-null-keyword
259
+ }
255
260
recordLog = undefined ;
256
261
}
257
262
} ;
258
263
264
+ function generateTsconfig ( newLog : IOLog ) : undefined | { compilerOptions : ts . CompilerOptions , files : string [ ] } {
265
+ if ( newLog . filesRead . some ( file => / t s c o n f i g .+ j s o n $ / . test ( file . path ) ) ) {
266
+ return ;
267
+ }
268
+ const files = [ ] ;
269
+ for ( const file of newLog . filesRead ) {
270
+ if ( file . result . contentsPath &&
271
+ Harness . isDefaultLibraryFile ( file . result . contentsPath ) &&
272
+ / \. [ t j ] s $ / . test ( file . result . contentsPath ) ) {
273
+ files . push ( file . result . contentsPath ) ;
274
+ }
275
+ }
276
+ return { compilerOptions : ts . parseCommandLine ( newLog . arguments ) . options , files } ;
277
+ }
278
+
259
279
wrapper . fileExists = recordReplay ( wrapper . fileExists , underlying ) (
260
280
path => callAndRecord ( underlying . fileExists ( path ) , recordLog . fileExists , { path } ) ,
261
281
memoize ( path => {
0 commit comments