@@ -3,11 +3,11 @@ var fs: any = require('fs');
3
3
var path : any = require ( 'path' ) ;
4
4
5
5
function 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();' ) ;
7
7
}
8
8
9
9
function 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 + '");' ) ;
11
11
}
12
12
13
13
function instrument ( tscPath : string , prepareCode : string , cleanupCode : string = '' ) {
@@ -27,8 +27,12 @@ function instrument(tscPath: string, prepareCode: string, cleanupCode: string =
27
27
fs . readFile ( path . resolve ( path . dirname ( tscPath ) + '/loggedIO.js' ) , 'utf-8' , ( err : any , loggerContent : string ) => {
28
28
if ( err ) throw err ;
29
29
30
- var invocationLine = 'ts.executeCommandLine(sys.args);' ;
30
+ var invocationLine = 'ts.executeCommandLine(ts. sys.args);' ;
31
31
var index1 = tscContent . indexOf ( invocationLine ) ;
32
+ if ( index1 < 0 ) {
33
+ throw new Error ( "Could not find " + invocationLine ) ;
34
+ }
35
+
32
36
var index2 = index1 + invocationLine . length ;
33
37
var newContent = tscContent . substr ( 0 , index1 ) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent . substr ( index2 ) + '\r\n' ;
34
38
fs . writeFile ( tscPath , newContent ) ;
0 commit comments