@@ -3,11 +3,11 @@ var fs: any = require('fs');
33var path : any = require ( 'path' ) ;
44
55function instrumentForRecording ( fn : string , tscPath : string ) {
6- instrument ( tscPath , 'sys = Playback.wrapSystem(sys); sys.startRecord("' + fn + '");' , 'sys.endRecord();' ) ;
6+ instrument ( tscPath , 'ts. sys = Playback.wrapSystem(ts. sys); ts. sys.startRecord("' + fn + '");' , 'ts. sys.endRecord();' ) ;
77}
88
99function instrumentForReplay ( logFilename : string , tscPath : string ) {
10- instrument ( tscPath , 'sys = Playback.wrapSystem(sys); sys.startReplay("' + logFilename + '");' ) ;
10+ instrument ( tscPath , 'ts. sys = Playback.wrapSystem(ts. sys); ts. sys.startReplay("' + logFilename + '");' ) ;
1111}
1212
1313function instrument ( tscPath : string , prepareCode : string , cleanupCode : string = '' ) {
@@ -27,8 +27,12 @@ function instrument(tscPath: string, prepareCode: string, cleanupCode: string =
2727 fs . readFile ( path . resolve ( path . dirname ( tscPath ) + '/loggedIO.js' ) , 'utf-8' , ( err : any , loggerContent : string ) => {
2828 if ( err ) throw err ;
2929
30- var invocationLine = 'ts.executeCommandLine(sys.args);' ;
30+ var invocationLine = 'ts.executeCommandLine(ts. sys.args);' ;
3131 var index1 = tscContent . indexOf ( invocationLine ) ;
32+ if ( index1 < 0 ) {
33+ throw new Error ( "Could not find " + invocationLine ) ;
34+ }
35+
3236 var index2 = index1 + invocationLine . length ;
3337 var newContent = tscContent . substr ( 0 , index1 ) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent . substr ( index2 ) + '\r\n' ;
3438 fs . writeFile ( tscPath , newContent ) ;
0 commit comments