1- declare var require : any , process : any ;
2- var fs : any = require ( 'fs' ) ;
3- var path : any = require ( ' path' ) ;
1+ declare const require : any , process : any ;
2+ const fs : any = require ( "fs" ) ;
3+ const path : any = require ( " path" ) ;
44
55function instrumentForRecording ( fn : string , tscPath : string ) {
66 instrument ( tscPath , `
@@ -14,47 +14,48 @@ ts.sys = Playback.wrapSystem(ts.sys);
1414ts.sys.startReplay("${ logFilename } ");` ) ;
1515}
1616
17- function instrument ( tscPath : string , prepareCode : string , cleanupCode : string = '' ) {
18- var bak = tscPath + ' .bak' ;
17+ function instrument ( tscPath : string , prepareCode : string , cleanupCode = "" ) {
18+ const bak = ` ${ tscPath } .bak` ;
1919 fs . exists ( bak , ( backupExists : boolean ) => {
20- var filename = tscPath ;
20+ let filename = tscPath ;
2121 if ( backupExists ) {
2222 filename = bak ;
2323 }
2424
25- fs . readFile ( filename , ' utf-8' , ( err : any , tscContent : string ) => {
25+ fs . readFile ( filename , " utf-8" , ( err : any , tscContent : string ) => {
2626 if ( err ) throw err ;
2727
2828 fs . writeFile ( bak , tscContent , ( err : any ) => {
2929 if ( err ) throw err ;
3030
31- fs . readFile ( path . resolve ( path . dirname ( tscPath ) + ' /loggedIO.js' ) , ' utf-8' , ( err : any , loggerContent : string ) => {
31+ fs . readFile ( path . resolve ( path . dirname ( tscPath ) + " /loggedIO.js" ) , " utf-8" , ( err : any , loggerContent : string ) => {
3232 if ( err ) throw err ;
3333
34- var invocationLine = ' ts.executeCommandLine(ts.sys.args);' ;
35- var index1 = tscContent . indexOf ( invocationLine ) ;
34+ const invocationLine = " ts.executeCommandLine(ts.sys.args);" ;
35+ const index1 = tscContent . indexOf ( invocationLine ) ;
3636 if ( index1 < 0 ) {
37- throw new Error ( " Could not find " + invocationLine ) ;
37+ throw new Error ( ` Could not find ${ invocationLine } ` ) ;
3838 }
3939
40- var index2 = index1 + invocationLine . length ;
41- var newContent = tscContent . substr ( 0 , index1 ) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent . substr ( index2 ) + ' \r\n' ;
40+ const index2 = index1 + invocationLine . length ;
41+ const newContent = tscContent . substr ( 0 , index1 ) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent . substr ( index2 ) + " \r\n" ;
4242 fs . writeFile ( tscPath , newContent ) ;
4343 } ) ;
4444 } ) ;
4545 } ) ;
4646 } ) ;
4747}
4848
49- var isJson = ( arg : string ) => arg . indexOf ( ".json" ) > 0 ;
49+ const isJson = ( arg : string ) => arg . indexOf ( ".json" ) > 0 ;
5050
51- var record = process . argv . indexOf ( ' record' ) ;
52- var tscPath = process . argv [ process . argv . length - 1 ] ;
51+ const record = process . argv . indexOf ( " record" ) ;
52+ const tscPath = process . argv [ process . argv . length - 1 ] ;
5353if ( record >= 0 ) {
54- console . log ( ' Instrumenting ' + tscPath + ' for recording' ) ;
54+ console . log ( ` Instrumenting ${ tscPath } for recording` ) ;
5555 instrumentForRecording ( process . argv [ record + 1 ] , tscPath ) ;
56- } else if ( process . argv . some ( isJson ) ) {
57- var filename = process . argv . filter ( isJson ) [ 0 ] ;
56+ }
57+ else if ( process . argv . some ( isJson ) ) {
58+ const filename = process . argv . filter ( isJson ) [ 0 ] ;
5859 instrumentForReplay ( filename , tscPath ) ;
5960}
6061
0 commit comments