11/// <reference path="..\src\compiler\sys.ts"/>
22/// <reference path="..\src\compiler\types.ts"/>
33
4- module perftest {
5-
4+ namespace perftest {
65 interface IOLog {
76 resolvePath : ts . Map < string > ;
87 fileNames : string [ ] ;
@@ -12,20 +11,20 @@ module perftest {
1211 getOut ( ) : string ;
1312 }
1413
15- export var readFile = ts . sys . readFile ;
16- var writeFile = ts . sys . writeFile ;
17- export var write = ts . sys . write ;
18- var resolvePath = ts . sys . resolvePath ;
19- export var getExecutingFilePath = ts . sys . getExecutingFilePath ;
20- export var getCurrentDirectory = ts . sys . getCurrentDirectory ;
21- var exit = ts . sys . exit ;
14+ export const readFile = ts . sys . readFile ;
15+ const writeFile = ts . sys . writeFile ;
16+ export const write = ts . sys . write ;
17+ const resolvePath = ts . sys . resolvePath ;
18+ export const getExecutingFilePath = ts . sys . getExecutingFilePath ;
19+ export const getCurrentDirectory = ts . sys . getCurrentDirectory ;
20+ // const exit = ts.sys.exit;
2221
23- var args = ts . sys . args ;
22+ const args = ts . sys . args ;
2423
2524 // augment sys so first ts.executeCommandLine call will be finish silently
2625 ts . sys . write = ( s : string ) => { } ;
2726 ts . sys . exit = ( code : number ) => { } ;
28- ts . sys . args = [ ]
27+ ts . sys . args = [ ] ;
2928
3029 export function restoreSys ( ) {
3130 ts . sys . args = args ;
@@ -44,19 +43,19 @@ module perftest {
4443 return args . slice ( 1 ) ;
4544 }
4645
47- var resolvePathLog : ts . Map < string > = { } ;
48-
46+ const resolvePathLog : ts . Map < string > = { } ;
47+
4948 export function interceptIO ( ) {
5049 ts . sys . resolvePath = ( s ) => {
51- var result = resolvePath ( s ) ;
50+ const result = resolvePath ( s ) ;
5251 resolvePathLog [ s ] = result ;
5352 return result ;
5453 } ;
5554 }
5655
5756 export function writeIOLog ( fileNames : string [ ] ) {
58- var path = args [ 1 ] ;
59- var log : IOLog = {
57+ const path = args [ 1 ] ;
58+ const log : IOLog = {
6059 fileNames : fileNames ,
6160 resolvePath : resolvePathLog
6261 } ;
@@ -65,36 +64,36 @@ module perftest {
6564 }
6665
6766 export function prepare ( ) : IO {
68- var log = < IOLog > JSON . parse ( readFile ( args [ 0 ] ) ) ;
67+ const log = < IOLog > JSON . parse ( readFile ( args [ 0 ] ) ) ;
68+
69+ const files : ts . Map < string > = { } ;
70+ log . fileNames . forEach ( f => { files [ f ] = readFile ( f ) ; } ) ;
6971
70- var files : ts . Map < string > = { } ;
71- log . fileNames . forEach ( f => { files [ f ] = readFile ( f ) ; } )
72-
7372 ts . sys . createDirectory = ( s : string ) => { } ;
7473 ts . sys . directoryExists = ( s : string ) => true ;
7574 ts . sys . fileExists = ( s : string ) => true ;
7675
77- var currentDirectory = ts . sys . getCurrentDirectory ( ) ;
76+ const currentDirectory = ts . sys . getCurrentDirectory ( ) ;
7877 ts . sys . getCurrentDirectory = ( ) => currentDirectory ;
7978
80- var executingFilePath = ts . sys . getExecutingFilePath ( ) ;
79+ const executingFilePath = ts . sys . getExecutingFilePath ( ) ;
8180 ts . sys . getExecutingFilePath = ( ) => executingFilePath ;
8281
8382 ts . sys . readFile = ( s : string ) => {
8483 return files [ s ] ;
85- }
84+ } ;
8685
8786 ts . sys . resolvePath = ( s : string ) => {
88- var path = log . resolvePath [ s ] ;
87+ const path = log . resolvePath [ s ] ;
8988 if ( ! path ) {
9089 throw new Error ( "Unexpected path '" + s + "'" ) ;
9190 }
92- return path
93- }
91+ return path ;
92+ } ;
9493
9594 ts . sys . writeFile = ( path : string , data : string ) => { } ;
9695
97- var out : string = "" ;
96+ let out = "" ;
9897
9998 ts . sys . write = ( s : string ) => { out += s ; } ;
10099
0 commit comments